Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq Query to Compare with List of string values

Tags:

c#

linq

I need to compare and get the matching values from a string list with LINQ. Have a look at my code.

Code

Split = Id.Split(',');
List<string> uids = new List<string>(Split);
var model = (from xx in Db.ItemWeedLogs
                where xx.ItemNo == uids   
                // I need to pass a string list to extract the matching record.
                select xx).ToList();
like image 964
Dheyv Avatar asked Dec 20 '22 12:12

Dheyv


1 Answers

Try this :

var model = (from xx in Db.ItemWeedLogs
                     where uids.Contains(xx.ItemNo)
                     select xx).ToList();
like image 189
Wahid Bitar Avatar answered Dec 23 '22 01:12

Wahid Bitar