我无法创建 LINQ 请求。我有一个基本要求:
var result = from i in _dbContext.Users
where i.ID != CurrentUserID &&
//i.UserType.UserTypeID == (from a in _dbContext.UserTypes where a.UsersSelectMeetingCriteria.Any(p => p.ID == CurrentUserID) select a.UserTypeID).FirstOrDefault() &&
i.Services.Any(p => p.UsersSelectMeetingCriteria.Any(k => k.ID == CurrentUserID)) &&
i.GeographicalAreas.Any(p=>p.UsersSelectMeetingCriteria.Any(o=>o.ID == CurrentUserID)) &&
i.MultiplyItems.Any(r => (r.UsersSelectMeetingCriteria.Any(q => q.ID == CurrentUserID) && r.ItemType == MultiplyItemKeys.USER_TYPE)) &&
i.MultiplyItems.Any(s => (s.UsersSelectMeetingCriteria.Any(q => q.ID == CurrentUserID) && s.ItemType == MultiplyItemKeys.COMPANY_INVOLVED)
)
select new DataTable.UserModel()
{ ... };
但我需要 4 级搜索。如果所有 4 个位置都可以,那么这是第一级用户,如果只有 3 个(但第 4 个不是)- 级别 #2,如果 2 - 是,2 - 否然后级别 #3,如果只有一个匹配 - 级别 #4。怎么做?