please consider this image:

I have a table like this:
Age Active Men/Women
-------------------------------------------------
I want to write a query with linq to entities that calulate Count of every age intervals for men and women. I canusing let operator to calculate single row but I want to calculat All in one query.
thanks
I don’t think this is possible in Linq2Sql, but I came up with this Query:
First I define a Function to return the AgeGroup for a given age(
(age / 5) * 5gives the starting number for a AgeGroup). From there it’s pretty straightforward. Grouping the ages and add up the numbers.Edit:
I don’t think it’s possible in one query. Because
group byends a query(likeselect) and you need to group first and then add up.You can’t use
IQueryable, because theageGroup()Function is not know in SQL and therefore can’t be used in Linq2Sql.