score:0
Accepted answer
var query = (from wl in worklog
join td in taskdefinition on wl.taskdefinitionid equals td.id
join tg in taskgroup on td.taskgroupid equals tg.id
where wl.employeeid == { 0} && wl.status == 5
&& wl.starttime >= { 1} && wl.endtime < { 2}
select new
{
project = tg.project,
starttime = wl.starttime,
endtime = wl.endtime
})
.groupby(o => o.project)
.select(g => new
{
project = g.key,
hours = g.sum(o => (o.endtime - o.starttime).minutes) / 60
});
Source: stackoverflow.com
Related Query
- Map SQL with JOIN, GROUP BY, and SUM to Entity Framework query
- Entity Framework Linq, Left Join and group with SUM and Count
- Converting an SQL with Left Join , Group and Sum to a Linq Query
- Entity Framework - Linq query with order by and group by
- Linq to SQL Group by and sum in select with entity
- Create a entity framework LINQ group join query to return a subset of properties from DTO and a list of another DTO, ASP.net core
- Linq to SQL With Left Outer Join and Group By With Sum - How To
- How can I convert Sql query to Linq and its equivalent with Join() method in Entity Framework Core
- Group By and Sum In LINQ query with Join
- left join with group by and sum in linq to sql
- How sum a column in Entity Framework using linq and join it with another table
- Translating datediff LINQ query to SQL with Entity Framework Core and .NET Core 3.1
- Convert SQL query to linq/lambda expression with sum and group by condition
- convert SQL query with multiple join on multiple tables using group by on multiple columns and with aggregate function into LINQ
- LINQ Query with GROUP and SUM
- Entity Framework Group By with Max Date and count
- Simple sql to Linq query with group by and aggregate functions
- Always encrypted with Entity Framework and Includes fails to materialise query
- How can i write SQL update query with where clause in Entity Framework in C#
- Entity Framework gets progressively slow with extra join added even though SQL generated is fast
- Optimize SQL generated by LINQ Query in Entity Framework 4.1 with one-to-many associations
- How to map Integer to String with AutoMapper 3 and Entity Framework
- How to query many-to-many relationship with 'AND' condition using LINQ and Entity Framework
- Query a many to many relationship with Entity Framework and .NET 3.5
- LINQ to Sql Left Outer Join with Group By and Having Clause
- Join with Entity Framework and F#
- LINQ: Translating a SQL WITH clause to LINQ and Entity Framework
- Pull data from multiple tables in one SQL query using LINQ and Entity Framework (Core)
- Linq query with GROUP BY on multiple fields, SUM and COUNT
- Group By Query with Entity Framework
More Query from same tag
- Count duplicate objects in nested class by common field
- Linq query using only year part of datetime
- Why does SortedList in C# have no Find method?
- How to write LINQ for multiple joins involving self join?
- How can I query a db using linq to get related rows with a single call?
- How to manage multiple tables with the same structure
- Linq performance poor
- Correct way to create a custom comparer for linq join
- How to mix monadic constructs in a single Linq expression?
- ASP.NET MVC application users linq to join to other tables
- Left Outer Join using LINQ Method Syntax
- Result of join linq query to a viewmodel
- How to find child element from Json or class object using Linq
- LINQ GroupBy two object properties and SUM, AVG, or Ignore others using Lambda
- Create Dictionary and use key in value expression declaration
- Loop through List with Linq condition
- Select unavailable on TableCellCollection
- Linq.Dyanmic GroupJoin implementation
- Populate a LINQ table in code?
- SQL to Linq: left join
- Sorting a list of dictionary based on a key in C#
- How to return an access a split string while using LINQ?
- Group by multiple columns as if it was one column
- The cast to value type 'System.Single' failed because the materialized value is null for stored procedure
- Trying to figure out how to format what my linq statement returns
- LINQ to Entities does not recognize the method NotSupportedException
- Linq query that involves doing group by with two tables that are not directly connected
- Expression.Call groupBy then Select?
- Applying child collections to matching parents in the parent collection
- ASP.Net membership provider