2013-12-18 28 views
0

我正在使用simple.data orm。嘗試從表中獲取最大值。無法得到它的工作。simple.data orm:如何獲取最大值?

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

AMBest是表格。 版本是AMbest表中的字段。

我需要獲取最新版本,但我的代碼無法正常工作。有人可以幫我嗎?

順便說一句,如果AMBest爲空,我想爲latestVersion指定一個默認值0。

回答

3

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