我试图获取标记为 publid (DisplayFor = false) 或具有所需权限的文章 (DisplayFor = true; 并且 article.groups 包含授予的组;) 和 (GroupId = Guid.Empty 对于每个注册用户):
List<Group> groups = new UserBiz().Groups(AchaAuth.CurrentUserId);
var result = from HeadsupArticle article in ctx.HeadsupArticles
where article.GroupId == item.GroupId &&
article.Active &&
(!article.DisplayFor || (article.DisplayFor && article.Groups.Any(g =>
g.GroupId == Guid.Empty ||
groups.Select(i => i.GroupId).Contains(g.GroupId)
)))
select article;
问题是
Unable to create a constant value of type 'Achasoft.AchaCms.Models.Group'. Only primitive types or enumeration types are supported in this context.
我需要一个适当的 linq 查询,所以我不需要选择 1000 条记录来从中获取 10 条记录