string StrWhere = string.Empty;
StrWhere = " AND ID =5";
String StrQuery ="SELECT * FROM CITY_MAS WHERE + StrWhere";
I want to achieve the same in LINQ. Something along the lines of the following query…
var result = from c in db.CITY_MAS
where + StrWhere
select new { c.ID,c.Name)
You can use Dynamic Linq to dynamically add criteria.
See http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx