c# - group by select max in linq -



c# - group by select max in linq -

i'm trying find out how still confuse linq sytax.

my purpose find max effectivedate specify empcode

var x = (from workingresult in this.dataworkspace.applicationdata.workingresults grouping workingresult workingresult.employeecode g g.employeecode == employeecode && (g.effectivedate.hasvalue && g.effectivedate.value.equals(date)) select new {effectivedate = g.max(d=>d.effectivedate)});

but compiler shows me this

" not find implementation of query pattern source type'...'. 'groupby' not found. consider explicitly specifying type of range variable 'workingresult'. "

what means ? really need help. give thanks you.

the problem code treating grouping g if single workingresult. in reality list of them. furthermore, purpose of g.effectivedate.value.equals(date)? result in maximum effective date beingness date or nothing, if no effective date exists matches date variable.

the next should work:

dataworkspace.applicationdata.workingresults .where(x => x.employeecode == employeecode) .max(x => x.effectivedate);

this homecoming maximum effectivedate specified employeecode.

c# linq

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -