score:2
I think your Linq query is almost perfect you just need to select new ViewModels:
from c in Invoices
join i in InvoiceItems on c.InvoiceId equals i.InvoiceId
join pi in PaymentInvoices on c.InvoiceId equals pi.InvoiceId
select new InvoiceViewModel {
InvoiceId = c.InvoiceId,
CustomerName = c.CustomerName,
TotalofInvoice = c.InvoiceItems.Sum(invoiceitem => invoiceitem.Total(),
AmountAllocated = ...
Outstanding = ...
};
Source: stackoverflow.com
Related Articles
- Viewmodel and LINQ query to represent 4 linked tables in Asp.Net MVC
- LINQ query to MVC Viewmodel multiple tables and lists
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- LINQ to SQL: Complicated query with aggregate data for a report from multiple tables for an ordering system
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- linq query to join two tables and get the count from one table values from the other
- LinQ query with multiple tables and extracting data
- How to reuse a linq expression for 'Where' when using multiple source tables
- LINQ Source Code Available
- Joining tables in EF Core Linq Query
- linq - how do you do a query for items in one query source that are not in another one?
- How can I write the following code more elegantly using LINQ query syntax?
- How to dynamic add filters to a LINQ query against an Odata Source in C#
- C# Linq query help removing foreach loops creating cleaner code
- Use a linq query as microsoft local report Data Source (WinForms)
- Determine the source DataContext for a Linq to Sql query
- LINQ query returns old results when source list is re-initialized
- How to get SQL query into LINQ form in C# code
- How can I code a Linq query to do an upward Include?
- Using Linq to query linked server in Visual Studio
- Linq query to sum values from tables
- Linq Query to Get Distinct Records from Two Tables
- Populate a C# class from a dataset with multiple linked tables using linq lambda
- creating Linq to sqlite dbml from DbLinq source code
- LINQ Query To Join Two Tables and Select Most Recent Records from Table B corresponding to Table A
- Pull data from multiple tables in one SQL query using LINQ and Entity Framework (Core)
- Gettings grouped sums from related tables into linq query columns
- Identify source of linq to sql query
- NHibernate LINQ query performance, which code fragment is better?
- Linq sub query when using a repository pattern with EF code first
- how to use linq to get memory location?
- How to use the Version Class in a LINQ query on latest release folder
- EF5 and Lamba/Linq - how only Include some columns of related tables
- How can i use generic class to write useful codes via linq?
- Enumerating large data sets multiple times using LINQ to Entities
- JSON - how to find list of child elements based on count
- How can I use LINQ to filter a collection of nested classes to yield a dictionary of unique properties of those classes?
- ListView.AddRange of custom Object using LINQ
- Expression method for NULLIF (with Divide)
- ASP.NET CORE EF - LINQ statement
- Alternative Implementation of GetEnumerator() for IEnumerable<T> Wrapper
- How to create linq to get all records group by columnname
- Group data having unique keys and values
- Identifying duplicate datatable rows using LINQ
- Build SQL Where query from delegate
- Linq converting implicitly to type
- Help optimize this linq statement
- LINQ to SQL Group By Multiple Records in One Row
- Find a random content in the database - Linq
- Linq Include Select from Navigation Property