Click here to Skip to main content
15,074,483 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hiya

I am getting the following error when running my code. The code is:

C#
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
        }


Which produces the following error:

Could not format node 'OptionalValue' for execution as SQL.

Can anyone help?!
Posted

try this :
C#
var list= (from list in dc.tblList
                          where list.listID == listID
                          select (list.aspnet_User.aspnet_Membership.Email)).First();
   
Comments
Scrappy 1871 18-Feb-12 10:49am
   
That'll only provide the first element. What I want to be able to do is if the list is empty, be null, otherwise give me the list of related data.
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!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900