我们正在对组织结构使用问责制模式。我使用 linq 休眠来查找一些部门和职位,但我有两个问题。
var query =
Repository<Party>.Find(p => p.IsInternal == true)
.Where(p => p.Parents.Any(c => c.Parent.PartyId == id))
.Where(p =>
(
p.PartyType.PartyTypeId == (int)PartyTypeDbId.Department &&
_secretariat.Departments.Select(c => c.PartyId).Contains(p.PartyId)
)
||
(
p.PartyType.PartyTypeId == (int)PartyTypeDbId.Position &&
p.Children.Any(c =>
c.AccountabilityType.AccountabilityTypeId == (int)AccountabilityTypeDbId.TenurePersonOfPosition &&
((Person)c.Child).UserName != null)
)
);
首先:对于这部分查询,我得到了“未处理的表达式类型:1003”:“_secretariat.Departments.Select(c => c.PartyId).Contains(p.PartyId)”,并且我得到了 Property not found 'UserName'
我们有许多复杂的查询,我认为我们需要使用存储过程。
对不起英语不好!