簡體   English   中英

Linq查詢與字符串值列表進行比較

[英]Linq Query to Compare with List of string values

我需要比較並從字符串列表中獲取LINQ的匹配值。 看看我的代碼。

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();

嘗試這個 :

var model = (from xx in Db.ItemWeedLogs
                     where uids.Contains(xx.ItemNo)
                     select xx).ToList();

嘗試:

where uid.contains(xx.ItemNo)

我認為這更加快速和清晰。

var model = Db.ItemWeedLogs
              .Join(Id.Split(','), di => di.ItemNo, si => si, (d, s) => new {d})
              .ToList();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM