在Asp.Net获得Max By Linq [英] get Max By Linq in Asp.Net
本文介绍了在Asp.Net获得Max By Linq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用此代码获取最大值
i use this code to get max value
(From Tbl In db.tblRSInterests Select Tbl.intTrxId).Max()
但是如果表没有行(新表)给我BUG
BUT if table not have row (new Table) give me BUG
推荐答案
可以使用这个< br $>
can use this
Dim intID As Integer
Dim isHAVE As Integer
isHAVE = (From Tbl In db.tblRSInterests Select Tbl.intTrxId).Count()
If (isHAVE = 0) Then
intID = 1
Else
intID = (From Tbl In db.tblRSInterests Select Tbl.intTrxId).Max() + 1 ' Samer Al-Dwaik
End If
如果有人对我有好处
if any one have thing better till me
试试这个
Try this
Quote:
var maxLevelId = db.Characters.Where(o = > o.UserID == UserID)
.Max(o => o.LevelID);
var maxLevelId = db.Characters.Where(o => o.UserID == UserID)
.Max(o => o.LevelID);
这篇关于在Asp.Net获得Max By Linq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文