I am new to ET Core and I am looking for a way to group by week (DateTime column) and get the counts from LINQ.
Can someone please help me to do this?
Thanks.
I am new to ET Core and I am looking for a way to group by week (DateTime column) and get the counts from LINQ.
Can someone please help me to do this?
Thanks.
EF Core 2.0 doesn't implement GROUP BY.
You can use FromSql to execute a raw SQL query and map it to an entity, or you can create a VIEW and map it to an entity as if it were a table, eg :
class BlogPostCount
{
public int BlogID{get;set;}
public int Count {get;set;}
}
var query = "SELECT BlogID,Count(*) as Count from BlogPosts group by BlogID";
var counts = context.BlogPostCounts.FromSQL(query).ToList();