score:0
Accepted answer
var myobjects = (from m in db.myobjects
group m by new {m.name, m.anyotherproperty, ...} into grouped
select new myobjectwithcount()
{
myobject = grouped.firstordefault(),
count = grouped.count()
});
score:0
var myobjects = (from m in db.myobjects
group m by m.name into grouped
select new myobjectwithcount
{
name = grouped.key,
matchingobjects = grouped.tolist()
}).asqueryable();
Source: stackoverflow.com
Related Query
- LINQ - Entity framework code first - Grouped results to custom class
- Entity Framework 6 Code First Custom Functions
- Entity Framework LINQ projection into custom type results in missing data
- SQL subquery result in LINQ and Entity Framework Code First
- Entity Framework - Linq : how query to take 2 first ordered and grouped list
- how to select data by linq in many-to-many relationship in First code Entity framework 5
- Entity Framework LINQ Query using Custom C# Class Method - Once yes, once no - because executing on the client or in SQL?
- Does Linq in Entity Framework code first use SQL or does it get the whole table first?
- Getting InvalidCastException when trying to implement sorting in Entity Framework Code First using Linq
- c# WPF bind combobox to TPH in Entity Framework code first using LINQ
- Proper Linq Query for objects with many to many relation ship generated with code first entity framework
- Code First Entity Framework Linq Statement Returning Missing Records
- Entity Framework Code Most First Efficient Linq Query
- Entity Framework Code First - The entity or complex type cannot be constructed in a LINQ to Entities query
- Different results in Entity Framework than LINQ to SQL
- Entity Framework Code First without app.config
- Encrypting Decrypting Data via Entity Framework using separate class exposing encrypted/decrypted values: Linq statements fails
- Entity Framework query to custom object Class with List
- Make Entity Framework (using Linq queries) use alias of custom field instead of redoing the subquery
- Entity Framework Code First using context in Controller
- many to many mapping in entity framework code first
- How to Create a Run-Time Computed (NotMapped) Value in Entity Framework Code First
- Entity Framework Core LINQ Class Property/Methods can't use Included Property
- Linq to Entity Framework returned value results in error if not debugged
- updating data in many-to-many relationship in entity framework in code first existing database
- Entity Framework Code First String Comparison with Oracle Db
- most efficient Entity Framework Code First method of flattening / projecting parent entity with specific child
- Entity Framework Code First - Get blog posts which have certain tags
- Using custom method inside Linq Select with Entity Framework
- How to Query Icollections of Entity Framework Code First Data
More Query from same tag
- Implement left outer join using EF
- IS there a better extension method than FindIndex to filter on a generic list?
- Build expression on DataTable, design suggestion?
- Linq with alias
- Sum method in LINQ with long type
- Parse LINQ answer in a JSON
- how to execute method or DML in foreach loop as parallel to accelarate execution time?
- Cannot sort using System.Linq.Dynamic
- ListItemCollection - get text from value with LINQ
- "where T : X, new()" or "where T : new(), X"?
- C# algo required for creating cluster
- cannot convert type decimal to double
- How To properly perform arithmetic operations over Two List/Array
- Enumerable+WhereSelectEnumerableIterator`2 Error And Use LINQ statement to get values of JObject
- Getting 'Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken' when retrieving items from JSON
- How to scaffold a SQL Server database with ASP.Net Entity Framework
- Linq replace column value with another value
- LinQ how to change a integer like 1 to string 001
- In Linq to SQL how can you group children by a parent property
- Linq Query Optimization
- asp.net-MVC Self join in LINQ query
- Linq for xml parsing returns null element
- Entity Framework LINQ to Entities Join Query Timeout
- Azure WebJobs and models and SQL queries
- Check if values of Dictionary contains an element with certain field value
- Lazy loading or linq query?
- How to map to another object list with help of linq lambda select
- How could I use LINQ to filter out strings starting with a variety of sub-strings?
- Nhibernate Linq In Clause
- how to use linq table as parameter?