score:1
Your query structure is:
from t in (
)
select new {
Column1 = .Sum(p => p.TotalUserActions), // here is the error
Column2 = .Sum(p => p.AllTotalPoints), // and here
}
You must use the t
alias in result, like this:
from t in (
)
select new {
Column1 = t.Sum(p => p.TotalUserActions),
Column2 = t.Sum(p => p.AllTotalPoints),
}
But you must have such fields in your resulting query, which is not true right now.
I think you should write your query in SQL and transmit it to LINQ step by step. Right now it's very confusing and bug producing.
Update:
You've got the error because of your code doesn't contain such fileds. What should contain fields TotalUserActions
and AllTotalPoints
? Try to sum all Points
fields, but can't say what the TotalUserActions
is:
from t in (
)
select new {
Column1 = t.Sum(p => p.TotalUserActions),
Column2 = t.Sum(p => p.Points),
}
Source: stackoverflow.com
Related Articles
- Linq Anonymous type members must be declared in Sub Query
- LINQ: Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access
- Linq error generic parameter or the query must use a nullable type
- LINQ select query with Anonymous type and user Defined type
- LINQ query with GROUP BY and Count(*) into Anonymous Type
- Convert KeyValuePair to anonymous type in a LINQ query
- linq query anonymous type cannot be converted to POCO object
- How to convert Anonymous Type to Strong Type from LINQ query
- What is the return type for a anonymous linq query select? What is the best way to send this data back?
- conditionally populating anonymous type member in linq query
- How to turn LINQ query into anonymous type
- Return Anonymous type from LINQ query in VB.NET
- .NET service OData return anonymous type from LINQ query
- Convert nullable int to int in linq query return anonymous type
- Possible to assign a data type to an anonymous type's members in a linq query?
- Setting all properties of dynamic object in anonymous type in linq query
- nested Linq Query Returned an error at run time(Unable to create a constant value of type Anonymous type)
- How to create an anonymous type within linq query with TypeScript
- How to Select top (5) contributors group by Business type code in c# linq query
- error when anonymous type is used in join query in LINQ
- Why is this linq query with anonymous type faster than anything else I try?
- How to access anonymous type projected in Linq query in the next chained extension method?
- Using LINQ to query three entitites. - Include path expression must refer to a navigation property defined on the type
- give type to anonymous type in linq query
- Linq Query return Anonymous Type Error
- returning specified type for a linq query with anonymous type
- why can I only access the properties of an anonymous type when I add .toList to the end of my linq query
- Problem referring to members of an anonymous type in linq
- How to return an object (or a list of objects) of anonymous type from a LINQ query to the UI (Console App) in C#?
- string parsing in linq query and use anonymous type
- Enumerable.Concat not working
- filtering a list using LINQ
- Umbraco True/False custom property value parsing issue
- Search string in cdata block
- Unable to use .contains() with LINQ to Entities
- A better way than using ViewBag
- Alternative for LINQ's .Contains()
- JOIN using LINQ LAMBDA
- Updating cache object that contains collection of employees
- How to compare the elements of an char array using LINQ?
- Can I use linq's method of pluralizing a term?
- LINQ to Entities - How to return a single string value from entity
- Database is locked when inside a foreach with linq without ToList()
- OrderBy clause before Where clause - performance?
- Converting linq result set to data table
- linq if statement problem
- Retrieve images from database using linq mvc c#
- Way to select from multi list
- How to Filter a 2-dimensional List?
- How To Join Tables from Two Different Contexts with LINQ2SQL?