Hi, This post will show you, How to apply multiple or complicated condition with Entity framwork dbContext toList method using the where clause. If you are coming first time to this post, please read my post for Entity Framework Introduction. Example of this post-based Entity Framework Introduction.
Demo Table Data
Code
And condition
dbConnection
db = new dbConnection();
List<StuModel>
data = new List<StuModel>();
data =
db.stulist.Where(b=>b.roll>105 && b.city=="vns").ToList();
Output :
Or Condition
dbConnection
db = new dbConnection();
List<StuModel>
data = new List<StuModel>();
data =
db.stulist.Where(b=>b.roll>105 || b.city=="vns").ToList();
Order By
Ascending
data =
db.stulist.Where(b=>b.roll>105 || b.city=="vns").OrderBy
(b=>b.roll).ToList();
Decending
data = db.stulist.Where(b=>b.roll>105
|| b.city=="vns").OrderByDescending (b=>b.roll).ToList();
No comments:
Post a Comment