tags:

views:

86

answers:

2

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.

+2  A: 

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.

Robin Day
So how does he convert it to LINQ?
Andomar
A: 

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())
solairaja
-1 "into CalYear = Year(Now())" does not make sense (will remove downvote if you prove me wrong)
Andomar
have u checkd the link i have given, that have the proof.
solairaja
Right, it's VB.NET. Apologies and downvote removed!
Andomar
kindly vote when u accept the answer
solairaja