score:0
It looks like you may need to use the "let" keyword c# linq supports,
Here is an example (from LinqPad)
from p in Products let spanishOrders = p.OrderDetails .Where (o => o.Order.ShipCountry == "Spain") where spanishOrders.Any() orderby p.ProductName select new {
p.ProductName,
TotalValue = spanishOrders.Sum (o > => o.UnitPrice * o.Quantity) }
Source: stackoverflow.com
Related Articles
- LINQ - Foreign Key Data and Expression Trees
- c# Linq or code to extract groups from a single list of source data
- Are LINQ expression trees proper trees?
- Are LINQ expression trees Turing complete?
- Linq Expression Trees in Compact Framework
- Learning expression trees in LINQ
- Construct a LINQ GroupBy query using expression trees
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- LINQ - using a query expression to calculate data time difference
- How to reuse a linq expression for 'Where' when using multiple source tables
- How do I report progress while executing a LINQ expression on a large-ish data set
- How does linq actually execute the code to retrieve data from the data source?
- LINQ Source Code Available
- How to call a lambda using LINQ expression trees in C# / .NET
- Casting LINQ expression throws "Internal .NET Framework Data Provider error 1025."
- Merge duplicate data without affecting others in LINQ code
- Build Any() with Expression Trees for LINQ Queries
- Use a linq query as microsoft local report Data Source (WinForms)
- Generating a LINQ query using Expression Trees
- What is the max LINQ Expression Trees can do?
- At what point is a LINQ data source determined?
- Need LINQ expression to filter table based on foreign key values
- Linq query makes all calls to bring foreign key's table data
- creating Linq to sqlite dbml from DbLinq source code
- Linq to Sql: Optimizing lamba expression - clean code
- read icollection data using LINQ in C# code
- ORing LINQ Query, built using expression trees
- Linq to sql as object data source - designer problem with partial classes
- C# LINQ How to get a data source from a db?
- Using LINQ query result for data source for GridControl c#
- Pass a lambda as a variable to a .Select()
- Alternative ways to convert data table to customized XML
- What is the complexity of this LINQ example?
- Linq Lambda - Most viewed page
- A Shortcut for c# null and Any() checks
- LINQ multiple where clause
- When writing file 3 lines are deleted, and should not
- linq to xml skipwhile() takewhile()
- Using LINQ to return just two specific DataTables in a DataSet with several DataTables
- Random LinQ-SQL errors and sudden database closing
- cannot cast expression of type 'system.xml.linq.xelement to type yyy
- LINQ to SQL Where Clause Optional Criteria
- Group By Multiple Columns - LINQ
- How to search custom config section by key
- How to do this in ADO.NET Entities Framework
- How is managed the iteration here?
- Linq query to display number of users registered based on month
- Query for fetching data from joining table
- Asp.Net Linq and XML query
- Linq not equal to returning all values in wpf datagrid