使用LINQ to SQL和defaultifempty()的问题 [英] Problem using LINQ to SQL and defaultifempty()
本文介绍了使用LINQ to SQL和defaultifempty()的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hiya
运行代码时出现以下错误.代码是:
Hiya
I am getting the following error when running my code. The code is:
var list= (from list in dc.tblList
where list.listID == listID
select (list.aspnet_User.aspnet_Membership.Email)).DefaultIfEmpty();
if (list != null)
{
//insert code here
}
会产生以下错误:
无法格式化节点"OptionalValue"以执行为SQL.
有人可以帮忙吗?!
Which produces the following error:
Could not format node ''OptionalValue'' for execution as SQL.
Can anyone help?!
推荐答案
尝试一下:
try this :
var list= (from list in dc.tblList
where list.listID == listID
select (list.aspnet_User.aspnet_Membership.Email)).First();
我使用了.count ();获取记录的数量,然后获取条件为if>的if语句. 0 ...解决了它.可能更简单的方法,但这就是我所使用的方法!
I used a .count(); to get the amount of records, and then an if statement with the condition if > 0 do... which has solved it. Probably easier ways but that''s the one I''ve gone with!
这篇关于使用LINQ to SQL和defaultifempty()的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文