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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.