score:0
Accepted answer
SELECT COUNT(*) AS [ProductCount],
SUM([t].[NewProduct]) AS [NewProductCount],
SUM([t].[UpdatedProduct]) AS [UpdatedProductCount]
FROM (
SELECT [p].[Id], CASE
WHEN [p].[CreatedAt] > @__Parse_0
THEN 1 ELSE 0
END AS [NewProduct], CASE
WHEN [p].[UpdatedAt] > @__Parse_1
THEN 1 ELSE 0
END AS [UpdatedProduct], 1 AS [Key]
FROM [Products] AS [p]
) AS [t]
GROUP BY [t].[Key]
score:0
var total = _db.Products.Count();
var NewProducts = _db.Products.Count(s => s.CreatedAt > crDate.Date);
var UpdatedProducts = _db.Products.Count(s => s.UpdatedAt > updDate.Date) ;
Source: stackoverflow.com
Related Query
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- How do I convert this SQL query to LINQ to SQL
- How to convert this SQL query to LINQ or Lambda expression?
- How to convert this complex SQL Query with Subqueries into LINQ
- Convert this SQL Query to LINQ Query
- How to convert this String-based sql query to use Linq
- How to convert SQL to linq for this query
- Convert this SQL query to LINQ using .GroupBy() methods
- Convert this SQL query to LINQ to SQL
- How can I convert this SQL query to LINQ
- Need to Convert this SQL query to LINQ
- How to convert this SQL query to Linq
- Can anyone convert this SQL query into a C# Linq statement?
- Convert this SQL query into Linq
- How do I convert this SQL inner join query into LINQ syntax?
- Convert this SQL query to Linq (Not Exists + sub query)
- How to convert this SQL query to LINQ or Lambda expression in C#?
- How to convert this query from SQL to LINQ
- Convert this SQL Query to a Linq Lambda Expression
- How to convert this sql query into linq query. I am stuck at the group by and sum part
- How to convert this query string into LINQ to SQL query?
- How to convert this Sql query to LINQ query
- How to convert this SQL query to Linq to Entity query?
- Help me convert this SQL query to LINQ
- How can I convert this query from SQL to linq
- I want to convert this SQL query to linq using C#
- Is it possible to convert this SQL query to linq?
- How to convert this SQL Query to LINQ Query?
- Convert this query to Linq to SQL
- Convert SQL to LINQ Query
More Query from same tag
- Dynamic Columns from List using LINQ
- Basic LINQ to Object codes
- Intersect Anonymous Types with Lambda Comparer
- Quicksort using LINQ
- LINQy way to check if any objects in a collection have the same property value
- C# LINQ to merge two breakup
- simple linq issue, but I can't figure it out
- LINQ LEFT JOIN to another LEFT JOIN
- Any performance difference between using variables or constants in Entity Framework query?
- DataTable to Xdocument Custom
- Entityframework core query related data filtering
- How to preserve list values after linq operation?
- Combining a list of objects with periods into unique lists
- How to join unknown number of lists in LINQ
- Entity Framework Passing Table Value in Parameter Of a Function
- How do I optimize checking for any added, deleted or updated items on a list with Linq to Objects?
- Split elements of a list and retrieve only the first part from the split
- Multiple context queries inside a query
- Why does this LINQ query new up only one instance of the internal List?
- Linq OData REST API to Query a SharePoint List
- Placing values from a joint table in a class in C#
- How can generate a sequence number inside a LINQ select?
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- Get only one value from the table using LINQ
- What's the method based syntax equivalent of join into
- Search dynamically in fields of class(each time by other field)
- How does this LINQ query get initial values for this string?
- LINQ to Entities does not recognize the method, and this method cannot be translated into a store expression
- Dynamically filtering a column/property in to an EF 4.1 query using C#
- Group by in linq