Reputation: 3147
I am trying to filter List on following SQL query format;
SQL
SELECT * FROM Tracker
where (TrackProposalID = 6 and TrackRequestID = 0) or TrackRequestID = 16
Linq
I have tried this so far but getting syntax error;
listT = CType(listT.Where(Function(o) (o.TrackProposalID = 6 And o.TrackRequestID = 0) or (o.TrackRequestID = 16)).ToList
Upvotes: 1
Views: 1148
Reputation: 519
var result = listT.Where(x => x.TrackRequestID == 16 || (x.TrackProposalID == 6 && x.TrackRequestID == 0))
if you won't make ToList(). it will execute every calls to "result". so i recomend make ToList().
Upvotes: 0
Reputation: 14604
Try this
listT = listT.Where(x=>(x.TrackProposalID == 6 && x.TrackRequestID == 0) || (x.TrackRequestID == 16).ToList();
Upvotes: 1
Reputation: 1325
var newList = listT.Where(x=>(x.TrackProposalID == 6 && x.TrackRequestID == 0) || x.TrackRequestID == 16).ToList();
Upvotes: 0
Reputation: 3306
in C#
listT = listT.Where(o => (o.TrackProposalID == 6 && o.TrackRequestID == 0) || o.TrackRequestID == 16).ToList();
Upvotes: 2