如何使用Where子句获取实体类型的列表
本文关键字:类型 列表 实体 获取 何使用 Where 子句 | 更新日期: 2023-09-27 17:49:33
在我的情况下,我想要实体类型的列表,其中特定id匹配。
这是我的代码,谁能告诉我正确的代码如何实现这一点,谁能写正确的代码,我如何实现。
这里是我的代码
public static List<Institute> GetInstitutions(long OrgID)
{
using (SchoolGapEntities1 Db = new SchoolGapEntities1())
{
if (Db.Institutes.Any(I => I.INS_FK_ORGID == OrgID))
{
return Db.Set<Institute>().Where(I => I.INS_FK_ORGID == OrgID).ToList();
}
}
// return Db.Set<Institute>().Where(I => I.INS_FK_ORGID == OrgID).ToList();
}
使用Where
方法:
public static List<Institute> GetInstitutions(long OrgID)
{
using (SchoolGapEntities1 Db = new SchoolGapEntities1())
{
return Db.Institutes.Where(I => I.INS_FK_ORGID == OrgID).ToList();
}
}