如何处理null表linkq [英] how to handle null table linkq
本文介绍了如何处理null表linkq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于T 的给出错误,无法将null值分配给System.Int32类型的成员非可空值类型。
这里,我有Null表'Rate'
我不会得到最大值没有。 of rate.id(主要和自动增量)。
这里的问题是如果表是空的那么它显示错误
我该如何处理呢
its give error for "The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type."
Here, i have Null table 'Rate'
and i wont to get max no. of rate.id (primary and Auto Increment).
here problem is that if table is Empty then it's show Error
how can i handle it
DataClasses1DataContext dm = new DataClasses1DataContext();
var item = dm.Rates.Max(o => o.Id);
item = (item) + 1;
lblSrno.Containt=item.Tostring();
请帮帮我
please help me
推荐答案
试试这个...
Try this...
int? intIdt = db.Users.Max(u => (int?)u.UserId);
请参阅此链接以获取解释。
Null MaxId [ ^ ]
您可以尝试以下代码。
var item = dm.Rates.Max(o => {if(o!= null && o.id!= null){return o.id;}});
You can try the below code.
var item = dm.Rates.Max(o => {if(o!=null && o.id!=null){ return o.id; } });
你好,
你可以写这样的
Hi,
You can write like this
try
{
DataClasses1DataContext dm = new DataClasses1DataContext();
var item = dm.Rates.Max(o => o.Id);
if(item==null)return;
item ++;
lblSrno.Containt=item.Tostring();
}
catch{
}
检查它是否适合您..
Check it whether it is working for you..
这篇关于如何处理null表linkq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文