gpt4 book ai didi

c# - LINQ to Entities Group By 表达式给出 'Anonymous type projection initializer should be simple name or member access expression'

转载 作者:可可西里 更新时间:2023-11-01 03:04:26 29 4
gpt4 key购买 nike

我在这个表达式中遇到了上述错误:

var aggregate = from t in entities.TraceLines
join m in entities.MethodNames.Where("it.Name LIKE @searchTerm", new ObjectParameter("searchTerm", searchTerm)) on t.MethodHash equals m.MethodHash
where (t.CallTypeId & (int)types) == t.CallTypeId && t.UserSessionProcessId == m_SessionId
group t by m.Name into d
select new
{
d.Key,
d.Sum(x => x.InclusiveDurationMilliseconds) // <- squigglies on this line
};

知道是什么导致了这个错误吗?

最佳答案

做类似的事情:

select new
{
d.Key,
Sum = d.Sum(x => x.InclusiveDurationMilliseconds)
};

它可以从另一个属性中投影属性名称,但不能从方法中投影....

关于c# - LINQ to Entities Group By 表达式给出 'Anonymous type projection initializer should be simple name or member access expression',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3097385/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com