[英]Making this query in LINQ-SQL?
我有Employees
, Groups
和EmployeeGroupFilters
。
Employee
具有具有外键关系的GroupID
。
EmployeeGroupFilter
具有雇员和组ID。 每个员工可以过滤他们不想在日历中看到的组。
因此,如果存在EmployeeGroupFilter
,则该员工将看不到该组。
我需要一个查询,该查询将返回IEnumerable
of Group,这将是对员工可见的组。
例如:从“组”中选择所有组,其中“组”不在currentEmployee的“组”筛选器中。
现在,我可以像这样获取所有员工过滤器:
public static IEnumerable<EmployeGroupFilter> GetAllByEmployee(
int employeeID)
{
KezberPMDBDataContext db = new KezberPMDBDataContext();
return from p in db.EmployeGroupFilters
where p.EmployeID == employeeID
select p;
}
我需要类似的东西:
public static IEnumerable<Group> GetAllVisibleEmployeeGroups(
int employeeID)
{
KezberPMDBDataContext db = new KezberPMDBDataContext();
return from p in db.Groups
.......
select p;
}
return from p in db.Groups
where !p.EmployeGroupFilters.Any(fil=>fil.EmployeeId == employeeID)
select p;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.