سؤال

I am using simple.data orm. try to get the max value from the table. couldn't get it work.

var latestVersion = _db.AMBest.Version.Max();

AMBest is the table. Version is the the field in AMbest table.

I need to get the latest version, but my code does not working. can someone please help me out?

btw, if AMBest is empty, I want to assign a default value 0 for latestVersion.

هل كانت مفيدة؟

المحلول

var latestVersion = _db.AMBest.All().Select(_db.AMBest.Version.Max()).ToScalarOrDefault<int>();

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top