I have this existing Sql statement:
Select Count(ordid),isnull(prcsts,'NOT STARTED')
from lwp
where lwp in( Select max(Id) from lwp group by ordid)
group by prcsts
I want to convert to use linq-to-sql, but I'm can't figure out how to handle the group by
expression in the sub query. How can I do this?
I am using Entity Framework where I have a method to get the list of lwp. I did only part of it.
Entitydb.lwpmethod
.GetList
.Where(Function(F) F.ID = **Max(Function(O) O.ordid**)
.GroupBy(Function(F) F.prcsts)
.Select(Function(F) New With {.A = F.Count, .B = F.Key})
.ToList
I am unable to write the group by subquery in the max function.