Reputation: 3381
Could you help me convert this SQL statement to Linq? I have done an IN before but the GROUP BY, ORDER BY and TOP are parts I haven't done before.
SELECT TOP 300 lower(UserName) FROM UserHistory
WHERE LOWER(UserName) IN (SELECT Lower(UserName) FROM ActiveUsers)
GROUP BY LOWER(UserName)
ORDER BY MAX(Date) DESC
Upvotes: 0
Views: 788
Reputation: 3575
GROUP BY is done in Linq by:
group 'result here' by 'field here'
ORDER BY is done in Linq by:
.OrderBy('lambda expression here')
or
orderby //field here ascending | descending
TOP is done in Linq by:
.Take('number here');
NOTE: the arguments are not strings, just a way to say you have to put the correct value there.
Upvotes: 1