【发布时间】:2019-04-07 04:15:06
【问题描述】:
我怎样才能让“相交”在 Linq 查询中为部分单词匹配返回 true?我需要一个.Contains() .Intersect() 的混合体。
List<string> sParams = new List<string>(){"SAND", "PURPLE"};
//One of my Prices has the color "Sanddust"
Prices.Where(x => x.Color.ToUpper().Split(null).Intersect(sParams).Any());
上面的查询只返回精确的字符串匹配相交,但我需要返回true,因为字符串“SANDDUST”包含“SAND”。
【问题讨论】: