score:2
from c in db.customers
let thecount = c.orders.count()
select new {c.fname, c.lname, thecount}
http://msdn.microsoft.com/en-us/library/bb425822.aspx#linqtosql_topic11
these access operations translate to more complicated joins or correlated sub-queries in the equivalent sql, allowing you to walk through your object graph during a query.
score:6
from c in customers
join o in orders on c.customerid equals o.customerid into g
select new { c.fname, c.lname, count=g.count() }
Source: stackoverflow.com
Related Query
- linq query to join two tables and get the count from one table values from the other
- LINQ Query To Join Two Tables and Select Most Recent Records from Table B corresponding to Table A
- How to join two tables using Linq and count the rows of one column matched records
- Linq query to join two tables and return object from first table - PagedList used
- LINQ - joining two tables and getting the values from the right part of the join if it exists throw exception
- Left join on two Lists and maintain one property from the right with Linq
- LINQ query to conditionally filter on a where clause and select the values from another table
- Linq query to select data from table and join 2 tables
- Entity Framework Core: join two tables and get the properties I want using LINQ
- Linq join two tables and Get a count column
- How to count write the linq query when the grouped bY column is in one table and the items are in another table
- Linq join - show all data in one table and supplement with data from two others
- Linq Query to filter Table 1 and get count from Table 2
- How can we get list of two column say firstname and lastname from customer table in mvc using linq query
- Linq query to join 2 lists of objects and get the altered values as list
- Take the first five elements and the last five elements from an array by one query using LINQ
- linq join query get single record from second table
- Joining two tables with LINQ while also returning null records from the second table
- LINQ to Entities, join two tables, then group and take sums of columns from both tables
- How to join two table from two different edmx using linq query
- Linq Query to Get Distinct Records from Two Tables
- Pull data from multiple tables in one SQL query using LINQ and Entity Framework (Core)
- Get only one value from the table using LINQ
- Combining two datatable and getting the amount from second table by using linq
- Linq query to get all values from between two dates
- How to get only two fields from the table by linq query?
- Linq join two tables and count column
- How to filter LINQ query by table column and get count
- Linq query to get get count from multiple tables
- combine 2 queries from the same table into one linq query
More Query from same tag
- Replacing old sql written in asp.net with Linq
- MVC 3 get days of month in table columns
- Property set method not found (expression, audited entity)
- EF6 How to query where children contains all values of a list
- How to query records based on date
- why my linq query is not giving me expected results
- How to select Closest distance from each category
- Count and select values of of a JArray with json.net
- one2many relation, get parent with child
- wrong value in result query so Null Reference Exception in Linq query
- How to Union two Queries in LINQ to Fluent NHibernate?
- InsertOnSubmit constraints
- The LINQ expression node type 'ArrayLength' is not supported in LINQ to Entities
- Problem with displaying data from the linq query
- Show duplicates from lists c#
- Avoiding repeating code with Linq query + optional params
- Need to filter a datatable on 2 columns which creates a unique combination?
- linq query with dynamic where clause
- LinqToSql Sub Entiity Multiple And Operators
- IEnumerable.Contains() keeps querying data source instead of memory
- Best way to check if value exists for a key in ILookup<string, string> using linq
- Creating a distinct list of custom type in C#
- Query Microsoft Access MDB Database using LINQ and C#
- EF6 - updating child objects in a list of parent object causes enumeration error
- Joining 3 tables and using a left outer join with linq in EF Core 3.1.1
- Can I rewrite the following code using LINQ?
- How to check if an element has two specific child?
- IQueryable does not append WHERE statement in SQL
- Linq Sum dynamic parameter
- EntityFramework 5 filter an included navigation property