C# 在LINQ-SQL中进行此查询?
我有C# 在LINQ-SQL中进行此查询?,c#,asp.net,sql,linq,C#,Asp.net,Sql,Linq,我有员工,组,以及员工组过滤器 Employee具有具有外键关系的GroupID EmployeeGroupFilter具有员工和组ID。每个员工都可以筛选他们不希望在日历中看到的组 因此,如果存在EmployeeGroupFilter,该员工将看不到该组 我需要一个查询,该查询将返回组的IEnumerable,该组将是员工可见的组 例如:从组中选择所有,其中组不在currentEmployee的组筛选器中 现在,我可以像这样获取所有员工筛选器: public static IEnumerabl
员工
,组
,以及员工组过滤器
Employee
具有具有外键关系的GroupID
EmployeeGroupFilter
具有员工和组ID。每个员工都可以筛选他们不希望在日历中看到的组
因此,如果存在EmployeeGroupFilter
,该员工将看不到该组
我需要一个查询,该查询将返回组的IEnumerable
,该组将是员工可见的组
例如:从组中选择所有,其中组不在currentEmployee的组筛选器中
现在,我可以像这样获取所有员工筛选器:
public static IEnumerable<EmployeGroupFilter> GetAllByEmployee(
int employeeID)
{
KezberPMDBDataContext db = new KezberPMDBDataContext();
return from p in db.EmployeGroupFilters
where p.EmployeID == employeeID
select p;
}
公共静态IEnumerable GetAllByEmployee(
国际雇员ID)
{
KezberPMDBDataContext db=新的KezberPMDBDataContext();
从db.EmployeGroupFilters中的p返回
其中p.employeeID==employeeID
选择p;
}
我需要像这样的东西:
public static IEnumerable<Group> GetAllVisibleEmployeeGroups(
int employeeID)
{
KezberPMDBDataContext db = new KezberPMDBDataContext();
return from p in db.Groups
.......
select p;
}
公共静态IEnumerable GetAllVisibleMemployeeGroups(
国际雇员ID)
{
KezberPMDBDataContext db=新的KezberPMDBDataContext();
从数据库组中的p返回
.......
选择p;
}
return from p in db.Groups
where !p.EmployeGroupFilters.Any(fil=>fil.EmployeeId == employeeID)
select p;