score:1
Accepted answer
datetime fromdate = new datetime(2011, 1, 1);
datetime todate = new datetime(2011, 1, 1);
var query = from p in db.payments
where p.type == 1 && p.position == 1 &&
p.date >= fromdate && p.date <= todate
group p by p.applicationno into g
select new {
applicationno = g.key,
cnt = g.count(),
amnt = g.sum(x => x.amount)
};
Source: stackoverflow.com
Related Query
- Get Sum of a field in Linq with Group by
- How do I get the MAX row with a GROUP BY in LINQ query?
- LINQ Lambda Group By with Sum
- Linq Sum with group by
- LINQ Query with GROUP and SUM
- Linq get sum of data group by date
- LINQ with Lambda expression - Join, Group By, Sum and Count
- DataTable: Get Max Value Using LINQ With Criteria Field (GroupBy)
- LINQ - Writing an extension method to get the row with maximum value for each group
- Get latest record and group with highest date - LINQ
- LINQ won't sum a group with a float? property
- C# Linq or Lambda expression Group by Week IEnumerable list with date field
- LINQ with group_concat - get linked tabe results in one field
- Trying to get distinct values using LINQ with database field as parameter
- Using linq group by to get from a list of objects with a DateTime property to a list with an interval StartDate, EndDate
- C# LINQ get objects with field value that do not match a string array blacklist
- How to get Sum from List in another List as a property with linq
- Linq query with GROUP BY on multiple fields, SUM and COUNT
- Linq to SQL Group by and sum in select with entity
- LINQ Join 2 Datatables and With SUM AND GROUP BY
- LINQ - Join 3 tables with group by and sum
- LINQ Group By Sum how do i return null for decimal type field
- Linq get top 9 groups plus sum of all other groups as the 10th group
- Linq group by in sum column from with where clause
- Trying to use Group to get Max on two columns with Linq
- Grouping and Sum some field with Sub query in LINQ
- Get Sum of Columns after its group using linq
- Linq to SQL With Left Outer Join and Group By With Sum - How To
- How to get list of keys in a dictionary with group by value with using LinQ
- Linq group by and sum with multiple tables
More Query from same tag
- LINQ - 100 Views - Same Columns - Generic Queries
- How to add more columns to a grouped result in LINQ?
- Compiled LINQ queries in .NET 4.5
- dynamic sort columns doesn't work in linq
- How to return multiple rows using LINQ lambda expression from SQL Server 2014?
- Linq: Operator '/' cannot be applied to operands of type 'object' and 'object'
- OrderBy list by a nested list
- linq distinct and select new query
- How to serialize an object by Linq Expression
- How to use LIKE Operator in LINQ to Entity Framework
- How to distinct a list using LINQ?
- How to connect 2 Lists into 1 Model
- Entity Framework -- How are Canonical Functions Different from Linq -- Linq-to-Entities vs Canonical Functions
- return message in linq
- Find items with same property from list and pick the cheaper of the two items
- How to walk through a SelectListItem Array with Linq - techniques?
- How to select two columns in one int array
- 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported
- .Net Core linq where with multiple List<int> and string
- How to get value of a specific xml element?
- Order by child records using dynamic field with entity framework
- Using Predicates as Key in Dictionary, Getting Error When Trying To Call Value
- LINQ Query To Select Between Unlike Generic Lists
- Loop through an ITable LINQ.Data LINQ to SQL
- What is the best way to mix VB.NET's Option Strict and the new Option Infer directives?
- Why is this Linq expression so much slower than the other?
- Create a List<T> with T being an anonymous type using LINQ in C#
- Queryable Linq Query Differences In Entity Framework
- Why does the Linq OrderBy extension not affect the list it is called on?
- ASP.NET MVC Controller recommendation for LINQ DataContext instantiation place