我在下面的查询中收到此错误。我搜索了其他类似的链接,但无法让它工作:
无法创建“匿名类型”类型的常量值。只要 在此上下文中支持原始类型或枚举类型。
var users = from a in GetUsers(EmployeeID)
group new { a } by new { a.EmployeeID } into g
select new UserMovement { EmployeeID = g.Key.EmployeeID };
var resulttst = from s in _repository.GenericRepository<STG_WDUsers>().GetAll()
join u in users on s.Employee_ID equals u.EmployeeID
where s.EffectiveDate != null && s.EffectiveDate > dtSixMonths
group new { s } by new { s.Employee_ID, s.Business_Unit, s.First_Name, s.Last_Name } into g
orderby g.Key.Employee_ID, g.Min(m => m.s.EffectiveDate)
select new UserMovement
{
EffectiveDate = g.Min(m => m.s.EffectiveDate),
EmployeeID = g.Key.Employee_ID,
FirstName = g.Key.First_Name,
LastName = g.Key.Last_Name,
BusinessUnit = g.Key.Business_Unit,
PreviousBU = null
};
答案 0 :(得分:2)
您收到此错误是因为您在转换为SQL的LINQ查询中使用了本地对象序列CREATE
。但users
对象没有翻译。您可以在LINQ中将本地序列用于SQL后端,但前提是它们包含原始值:
UserMovement