Search This Blog

Thursday, January 13, 2011

How to create Dynamic Where Clause in Linq

C# Method:

 public IQueryable GetProductList(string whereClause)
    {
        var query = context.ItemMaster_Stage
                              .Where(whereClause);
  
        return (IQueryable)query;
    }

Method calling:

IQueryable obj = new Products().GetProductList("it.ITEM_NAME == 'WEDDING BANDS'");

Here you can call this method with 'Where' clause as per your requirement.

No comments:

Post a Comment

Comments