score:1
Accepted answer
var serverNames = new string[]{"ServerX", "ServerY"};
var result = db.Processes
.Where(p => serverNames.Contains(p.ID) && p.Type == "Complete")
.GroupBy(p => p.ProcessTime)
.Select(g => new
{
ProcessTime = g.Key,
AmountOfProcesses = g.Count()
})
.OrderBy(x => x.ProcessTime);
score:1
var query1 = (from a in this.db.Processes
where (a.ID == "ServerX" || a.ID == "ServerY") && a.Type == "Complete"
group a by a.ProcessTime into b
orderby b.Key
select new {ProcessTime = b.Key, Count = b.Count()});
Source: stackoverflow.com
Related Query
- How to convert SQL query to LINQ with Orderby, Groupby
- How to convert this complex SQL Query with Subqueries into LINQ
- How to convert SQL query to Linq with GROUP BY on only date part of a datetime?
- Convert SQL query with multiple GroupBy columns to LINQ
- Convert SQL Distinct, Count & GroupBy to a Linq query with Navigation
- How can I convert Sql query to Linq and its equivalent with Join() method in Entity Framework Core
- Convert SQL query with GroupBy and Avg to LINQ
- How do I convert SQL Query with Ccase Switch to Linq Lambda
- Convert SQL with groupBy sub query to LINQ query
- How to convert a query with inner join in sql to linq
- How to convert sql query with addition and join to linq
- How to convert SQL query to LINQ lambda expression with Inner Join and subquery
- How do I most elegantly express left join with aggregate SQL as LINQ query
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- How convert sql with count to linq
- How do I convert this SQL query to LINQ to SQL
- How make LINQ query with GroupBy and LEFT JOIN
- How to convert this SQL query to LINQ or Lambda expression?
- How to convert SQL to LINQ with look-ahead (lead like query)
- Convert sql query with multiple inner joins to LINQ
- How can I issue a LINQ query to a SQL Server to check if a column value starts with a word?
- How to write SQL SELECT INNER JOIN with multiple conditions (with LIKE) query to LINQ to SQL
- how to convert from sql query to linq
- How to convert multiple SQL LEFT JOIN statement with where clause to LINQ
- How to convert an MySql query to Linq with count and attributes
- How to convert this String-based sql query to use Linq
- How can I convert my working SQL query to Linq (C#)?
- Convert Sql Query To linq using sum with group by
- Convert a sql query with a subquery into a linq statement
- How to convert sql inner join query into linq to sql query and convert into list
More Query from same tag
- Where clause in LINQ - C#
- Linq ConcurrentDictionary Roles and Users Many to Many
- how to convert this T-SQL statment to linq
- Safest way to get the Invoke MethodInfo from Action<T>'s Instance
- Entity Framework and diamond joins
- How to select multiple songs that are/were made by several artists in Entity Framework?
- How to store a value and its list of stings in a list
- C#: If condition in Linq where clause
- Expression.Call GroupBy then Select and Count()?
- linq query close my wpf application
- Apply a linq expression of an object to a list of items where that object is a propery of an item (Wrapper)
- LINQ To Entities Multiselect
- LINQ distinct is showing duplicates
- C# Linq Inner Join
- combine two queries into one one query
- c# - Extract first integer from a string
- C#/LINQ: Concatenating strings
- Loop structure to perist data using addwithValue
- How to incorporate List<string> field in GroupBy()
- How to join two datasource which return all rows and group by condition?
- Linq create an array of Dto objects, with an array in it
- Get records from table and related related table using Linq to entity
- How to pass comma separated values to LINQ query without for loop
- Using Anonymous Type from LINQ to SQL
- Looping through XElement items
- Orderby clause not working with drop down list in mvc
- How to use a HashSet in my LINQ query?
- OrderByDescending(o => o.X).OrderBy(o => o.Y) does not work properly
- C# Linq OrderBy based on condition
- Left Join using Linq with Lambda Expressions returning the Left table