How to use LinqKit for Linq
to Entity framework
Use LinqKit
predicateBuilder class in our code.
Add LinqKit dll in your application reference
and add library in your page like :
using
LinqKit;
Write the following code to achieve
your requirement for multiple dynamic where condition
var predicate = LinqKit.PredicateBuilder.True<tblInfo>();
predicate
= predicate.And(p => p.Name == "Ajay");
predicate
= predicate.And(p => p.City == 2);
var Res = objDB.tblInfoes.AsExpandable().Where(predicate);
AsExpandable() is must required for Linq to Entity
framework
No comments:
Post a Comment