实体框架使用int数组连接查询

ASP*_*ker 5 sql asp.net-mvc entity-framework

我的数据库上有3个表.

- -学生 - -

id - 名字

- -语言 - -

id - lang

---学生语言---(普通表)

id - studentId - langId

学生可以拥有更多语言.我想搜索具有int[]数组值的学生.但不是IN()- Contains(),它必须与and- &&运算符和此运算符int[]取值.

在sql =

`select t1.id, t1.name from Student t1 join StudentLanguage t2 
ON(t1.id=t2.studentId) where (t2.langId=1 and t2.langId=3 and t2.langId=5);`
Run Code Online (Sandbox Code Playgroud)

那么如何使用Entity Framework进行此查询?(... where new int[] { 1,3,5 })

ror*_*ory 0

尝试这样的事情......

resultArr = [];

For(int i = 0; i<arr.length; i++) {
    var result = db.Student.Where(s=>s.StudentLanguage.langId == arr[i]);
    resultArr.append(result);
}
Run Code Online (Sandbox Code Playgroud)