I am getting the above mentioned error with this expression:
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
};
Any idea what is causing this error?
Anonymous types typically are used in the select clause of a query expression to return a subset of the properties from each object in the source sequence. For more information about queries, see LINQ in C#. Anonymous types contain one or more public read-only properties.
In some cases, you might want to project a query to a new type, but the query would be your only use for the new type. Rather than create the type, you can project to an anonymous type.
The compiler gives them a name although your application cannot access it. From the perspective of the common language runtime, an anonymous type is no different from any other reference type, except that it cannot be cast to any type except for object.
Do something like:
select new
{
d.Key,
Sum = d.Sum(x => x.InclusiveDurationMilliseconds)
};
It can project a property name from another property, but not from a method....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With