Reputation: 2859
i fail while converting this sql to linq...
hope anybody do it.
SELECT Max([PersonalNumber]+1)
FROM TestTable
GROUP BY CalYear
HAVING CalYear=Year(Now())
Thanks.
Upvotes: 2
Views: 207
Reputation: 964
check out here --> http://blogs.msdn.com/vbteam/archive/2007/12/18/converting-sql-to-linq-part-5-group-by-and-having-bill-horst.aspx
From TestTable in a
Group By CalYear
into CalYear = Year(Now())
Upvotes: 2
Reputation: 102468
The HAVING clause is there to enable you to filter on the results of an AGGREGATE. In this instance you are filtering on the GROUP column which could just be filtered using a WHERE clause instead.
Therefore you do not need to produce a HAVING clause in LINQ. A simple WHERE clause will do the same.
Upvotes: 3