我收到此异常,无法创建类型' XXX'的常量值。在此上下文中仅支持原始类型或枚举类型。
我试图在linq exression中进行子查询, 我使用2个数据源dbContext来获取所有数据和从服务返回的语言列表。
objData = (from s in db.Search
let lan = langList
//join l in db.Language on s.LanguageId equals l.Id
join u in db.User on s.UserId equals u.Id
where u.Id == (UserId == Guid.Empty ? u.Id : UserId)
&& s.isActive == true
&& s.SearchId == SearchId
select new userModel.Search()
{
Language = (from l in lan
join sl in db.Search on l.Id equals sl.LanguageId
where (sl.Id == s.Id || sl.SearchId == s.SearchId) && sl.isActive == true
select new userModel.Language
{
Id = l.Id,
Name = l.Name,
Code = l.Code,
isActive = l.isActive,
CreatedAt = l.CreatedAt,
UpdatedAt = l.UpdatedAt,
DeletedAt = l.DeletedAt
}).ToList()
}).ToList();