mysql - Selecting Max from a nullable int field with LINQ -
i trying find biggest ordernumber(int?) in mysql database linq:
int maxordernumber = context.datacontext.purchaseorders.where(r=> (r.ordernumber.hasvalue)).max(r=>r.ordernumber);
but says: cannot implicitly convert type 'int?' 'int'. missing cast?
in understanding, first part of expression filters field those, has value.
you pretty close, should it:
int maxordernumber = context.datacontext.purchaseorders.where(r=> (r.ordernumber.hasvalue)).max(r=>r.ordernumber.value);
Comments
Post a Comment