score:3
Accepted answer
you can use the count
overload that accepts a predicate:
var results = from message in context.inbox
group message by message.name into g
select new
{
name = g.key,
unread = g.count(m => m.status == "unread"),
total = g.count()
};
Source: stackoverflow.com
Related Query
- LINQ Query with two COUNTs based on different parameters in Where statement
- Linq Query with a Where clause in an Include statement
- linq to sql query with multiple where parameters
- Linq statement with two where clauses
- Entity Framework - LINQ statement with WHERE clause based on NULLABLE parameter
- Query with LINQ where Context matches multiple parameters from a List of Objects
- C# LINQ join with conditional where clause on two different data sets
- Simplifying LINQ - Sum of a Col twice with two different where clause
- Linq query to db with dynamic where parameters
- LINQ query - Multiple where with multiple sub queries based on int array
- Sort List with two parameters but in different lines of code
- query entity with linq passing in two parameters
- The WHERE IN clause with two parameters in linq
- how to optimize linq query where Data is coming from two different databases?
- Refine Enumerable LINQ WHERE statement with repeated parameters
- LINQ Query with dynamic where clause based on search criteria that is NOT part of the returned object
- C# Return a Calculated Distance between two Lat/Long Coordinates within a Linq Query WHERE statement
- Interpreting Sql with where and having statement to linq giving different results
- Creating LINQ query with two parameters
- Saved projection expression for re-use in different linq expressions with two source objects
- Creating a LINQ query based on two Lists and object array for testing parameters
- How to use index/position with Where in LINQ query language?
- Linq query with Array in where clause?
- Get different and common items in two arrays with LINQ
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- convert string to DateTime in linq query with where clause?
- Where in Query with Array in LINQ
- LINQ distinct with corresponding counts based on a List property
- LINQ query with a WHERE clause with multiple conditions
- Entity Framework with Oracle using odp.net not taking parameters in linq query
More Query from same tag
- Entity Framework Exclude Fields Query Count and POCO best way
- Sorting, rounding and removing duplicates in a list of time stamps using LINQ
- JSon.net linq join
- How to return array of data as return type in my linq query?
- Which explicit type did I get back from Enumerable.Select
- How to parameterize a linq query?
- Linq Using Child Collection in Query
- C# linq null question
- The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced
- How to compare two list and get the differences from first list?
- Entity framework 4 not binding properly to datagridview
- Deserialize JSON in c# when the return dataset in not known
- Workarounds for using custom methods/extension methods in LINQ to Entities
- Getting a column by string name
- Refactor similar Linq Queries
- Intercept the 'Expression' property of IQueryable Provider and gets its e-sql
- MVC Linq .Random() wrong syntax
- Entity framework paging with extension method is slow?
- Replace XML-element with LINQ to XML
- How to search in generic list of ExpandoObject
- Get Attribute name using position from XElement
- Get nested UserRoles from User table
- Cant Get Data To Return To My Grid View Using Linq in ASP.NET
- Setting a List<T> to a linq query result causes timeout
- How to display Grid data with 'filtered' binding list
- Linq-to-SQL, pass Expression<Func<T, T>> to select method in query syntax
- General questions on .NET Entity Framework 4
- Retrieve the last 5 years data using Entity Framework Linq
- Generic Extension method for LINQ JOIN using 2 columns
- How do I add a record to a database with LINQ?