c# - 要选择的 Entity Framework 查询

标签 c# entity-framework linq-to-entities

同 table 人:SSN、姓名 表学生:SSN,学校

我想为那些不是学生的人获取所有 SSN。如何使用 Entity Framework 编写此代码?

最佳答案

var ssnList = Context.Peoples
                     .Where( p => !Context.Students
                                          .Any(s => s.SSN == p.SSN))
                     .Select( p => p.SSN).ToList();

关于c# - 要选择的 Entity Framework 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5107142/

相关文章:

c# - 带有 Dbcontext 的 ExecuteStoreQuery

c# - 使用 Linq 获取当前和上一个项目

c# - 如何解决 "The method ' Skip' 仅支持 LINQ to Entities 中的排序输入。”

c# - 使用 Entity Framework 将更改保存到 SQL Server 数据库时,一个或多个实体的验证失败

c# - C# 中的字节数组到字符串

c# - Debug.Assert-s 使用相同的错误信息。我应该将它提升为静态变量吗?

c# - 从 DirectoryInfo.GetFiles 返回的 FileInfo 没有指向文件?

c# - 如何使用 LINQ group by with where 子句

c# - 如何将 Entity Framework 5 中的 DateTime SELECT 转换为仅 SELECT 日期部分?

c# - Base64 在 SQL 中编码一个 utf8 字符串