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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -