How to handle nulls in linq to entities -
how handle null max value in linq entities statement?
int userlevelid = db.characters.where(o => o.userid == userid).max(o => o.levelid);
i'm not quite sure mean when count, since aren't referring count anywhere in code. if wonding how handle null o.levelid
this:
max(o => o.levelid ?? -1);
??
coalesce operator in .net
update
try this:
db.characters.where(o => o.userid == userid).max(o => o == null ? 0 : o.levelid);
Comments
Post a Comment