linq 其中列表包含列表中的任何内容 [英] linq where list contains any in list
本文介绍了linq 其中列表包含列表中的任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 linq,如何检索其属性列表与另一个列表匹配的项目列表?
Using linq, how can I retrieve a list of items where its list of attributes match another list?
以这个简单的例子和伪代码为例:
Take this simple example and pseudo code:
List<Genres> listofGenres = new List<Genre>() { "action", "comedy" });
var movies = _db.Movies.Where(p => p.Genres.Any() in listofGenres);
推荐答案
听起来像您想要的:
var movies = _db.Movies.Where(p => p.Genres.Intersect(listOfGenres).Any());
这篇关于linq 其中列表包含列表中的任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文