score:3
Accepted answer
var results = from q in query
group q by new {q.soldtocontactid,
firstname=q.contact.firstname,
lastname=q.contact.lastname} into g
select new leadbuyersbystateitem {
contactid = g.key.soldtocontactid,
firstname = g.key.firstname,
lastname = g.key.lastname,
contactcount = g.count()
};
Source: stackoverflow.com
Related Query
- Convert SQL Distinct, Count & GroupBy to a Linq query with Navigation
- Convert SQL query with multiple GroupBy columns to LINQ
- Convert SQL query with GroupBy and Avg to LINQ
- Convert SQL with groupBy sub query to LINQ query
- How to convert SQL query to LINQ with Orderby, Groupby
- need to convert sql join query with count into linq and pass it to view
- Convert SQL to linq expression with count
- How convert sql with count to linq
- Convert sql query with multiple inner joins to LINQ
- How to convert this complex SQL Query with Subqueries into LINQ
- How to convert SQL query to Linq with GROUP BY on only date part of a datetime?
- How to convert an MySql query to Linq with count and attributes
- Linq to Sql - Query list of distinct items with multiple joins
- LINQ query with distinct count
- Converting SQL Query into Linq (c#) with Distinct
- Convert Sql Query To linq using sum with group by
- Convert a sql query with a subquery into a linq statement
- Why do I need distinct with this LINQ query but not with SQL
- Convert Sql query with Group by and Having clause to Linq To Sql query in C#
- How can I convert Sql query to Linq and its equivalent with Join() method in Entity Framework Core
- Convert sql query with a join on a subselect to a linq statement
- Emulating an SQL Query with Count of linked records using Linq
- Convert SQL to Linq - Where, in, Groupby and Having count
- Trouble translating SQL query to LINQ with join and having count
- How do I convert SQL Query with Ccase Switch to Linq Lambda
- Transform sql query to linq with groupBy and months
- C# LINQ Lambda query with select, Where, Count and Distinct
- Convert SQL query to linq in C# with Entity Framework
- Convert SQL Query to LINQ ORDER BY, GROUP BY, COUNT
- How to convert a query with inner join in sql to linq
More Query from same tag
- Goto in the ElementAt extension method
- Translating query to lambda
- LINQ to Entities - Best way to accomplish this?
- Custom properties and lambda expressions
- Select all family from root node using LINQ?
- No Count() for IQueryable?
- C# LINQ: how to handle wildcard search?
- A valid delegate for IssuerSigningKeyResolver
- Linq query definition
- Is multiple .Where() statements in LINQ a performance issue?
- Infecting\transmitting value to the adjacent items of list, in C#
- How can I check things between 3 lists?
- How to Perform ToString On Property of an Entity Framework Model Using Reflection
- Linq OrderBy logic
- linq .Sum() not working with Short properties
- How do I do a group my select by a fixed number using Linq to objects?
- Can't get all tags from XML file
- Nullable Int comparison in Linq Expression Query
- Is the order of execution of Linq the reason for this catch?
- How to access oracle data using Linq through ADO.net?
- ASP.NET Core 5 Blazor WASM, gRPC, Entity Framework Core 5: many-to-many results in stack overflow
- Dynamic Linq using Or
- Why C# linq Distinct method is faster
- Contains method for comparing in multiple table
- Entity Framework: sort linked entities
- How to format json from the MVC 5 Controller like this?
- How to Zip concurrently two IAsyncEnumerables?
- Is there anyway to merge these two queries EF
- Filtering Windows logs using lambda expressions on non-IEnumerable types
- Updating XML file in C#