我想根据字符串列表过滤结果,如下所示:
List<string> filters = {"a", "b", "c", "d"};
var results = (from R in db.Entries
where R.word.StartsWith(filters[0])
||R.word.StartsWith(filters[1])
||R.word.StartsWith(filters[2])
||...
我不知道我的过滤器列表的长度,所以如何在LINQ中动态查询它?
提前致谢。
在Linq中,这有点不同,反之亦然
使用.Contains()
像这样的东西:
from r in db.entries
where filters.contains (r.word.substring(0,1))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句