score:7
Well I don't think I should do all your work for you but specifically the group by you are asking about could be done like:
...GroupBy(x => new { x.ID, x.FirstName, x.LastName })...
score:17
this is your lambda:
var scholars = db.Scholars.Join(db.Suspensions,
scholar => scholar.ID,
suspension => suspension.ScholarID,
(scholar, suspension) => new {scholar, suspension})
.Where(u => u.suspension.StartDate >= startDate &&
u.suspension.EndDate <= endDate)
.GroupBy(u => new { u.scholar.ID, u.scholar.FirstName, u.scholar.LastName })
.Select(u => new
{
FullName = u.Key.FirstName + " " + u.Key.LastName,
TotalSuspensionSum = u.Sum(x =>
x.scholar.Suspensions.Sum(y => y.SuspensionDays)
)
})
.OrderBy(x => x.FullName)
.ToList();
Source: stackoverflow.com
Related Articles
- Group By using more than two columns by Lambda expression
- Lambda expression using Join for something more than a simple key
- Join and Group By using Lambda Expression
- How to write the same code using Lambda Expression
- Max of 2 columns with multiple group by lambda expression entity framework
- How to filter entity framework result with multiple columns using a lambda expression
- Using LINQ Lambda expression determining value by group by and where condition
- Getting null reference error in linq expression when trying to join more than 2 tables using defaultifempty method
- How to group more than two tables using Linq
- Group by using inner property in a list using Lambda expression
- Using LinQ with group by more than one column
- Joins with more than 2 or 3 tables, with Where clause using Lambda Expressions. Then sending the object to the View
- Counting words with more than x characters in a string in C# using lambda expressions
- Convert Join to GROUP JOIN while using Lambda expression in linq c#
- Using Max, Group By, Join and Where in Lambda Expression
- Relate more than one column with lambda expression
- More than 1 group by statements in one query using Linq
- Find the category which has 3 or more than 3 products data by using the linq and lambda query
- Can you create a simple 'EqualityComparer<T>' using a lambda expression
- LINQ: Get all selected values of a CheckBoxList using a Lambda expression
- Simple Examples of joining 2 and 3 table using lambda expression
- linq to sql join on multiple columns using lambda
- Group by, Count and Lambda Expression
- How to query a nested list using a lambda expression
- How to order by multiple columns using VB.Net lambda expressions
- Selecting multiple columns with linq query and lambda expression
- how to group by multiple columns using linq
- Get N max numbers from a List<int> using lambda expression
- LINQ How to select more than 1 property in a lambda expression?
- Using a LINQ ExpressionVisitor to replace primitive parameters with property references in a lambda expression
- Learning about LINQ
- How to Join 2 Generic IEnumerators
- LINQ Union with Constant Values
- How can I get text and attributes values in my XML
- Compare two generic lists using Linq
- Linq: Sort child collection 2 levels down
- Why doesn't this Linq query bring back distinct (unique) results?
- How to get an IEnumerable<T1> of members of the class T2 in a Enumerable<T2> using Linq? (C#)
- LINQ reflection with Host Level Trust
- data continuously inserted in table
- not able to get the number of products count
- EF/LINQ : Find() operation
- What is the function evaluation requires all threads to run?
- how to use sum function with were condition and isnull check in linq to entity?
- Complex Dynamic LINQ Query
- LINQ for multiple count operations
- linq.sum is rounding
- cannot convert from 'System.Collections.Generic.IEnumerable<int>' to 'System.Linq.IQueryable<int?>
- Can i traverse a expression bodied member with an ExpressionVisitor?
- How to validate Linq join query?