I have a problem to create dynamic Where clause in LINQ Query.
I am try to use the following code in which i am filtering the multiple record of the same columns.
Code:
List<string> FilterList = new List<string>();
FilterList.Add("ABC");
FilterList.Add("ABD");
FilterList.Add("ABE");
var REFD = from dcodes in Program.LookupData.G_CODES.AsEnumerable()
where FilterList.Contains(dcodes.CODE_VALUE)
select new
{
CODE = dcodes.Field<string>("CODE_VALUE"),
DESC = dcodes.Field<string>("DESCR")
};
The above code filter a record just as like operator.
I am also trying to other way given below.
Code:
var REFD = from dcodes in Program.LookupData.G_CODES
.where("CODE_VALUE = 44 AND DESC = 'ddd' ")
.Orderby("CODE_VALUE")
select new
{
CODE = dcodes.Field<string>("CODE_VALUE"),
DESC = dcodes.Field<string>("DESCR")
};
IF there is any other best way to dynamically build the Query Please let me know about. thanks for early message.