4
Reply

C# check for null in linq

dc

dc

Sep 29 2012 3:06 PM
2.7k
For a C# 2010 application, I would like to be able to check for the value
returned by the linq to sql query listed below as being null.
Is there any way to check for

strOrgName == null?

string strOrgName = (from o in rData.Orgs
                  join pl in rData.Custs on o.OrgID equals pl.OrgID
                  where pl.orgnum == strContract
                  select o.OrgName).FirstOrDefault();

The code I have written so far only allows if I check for
strOrgName != null.

I am using the code above to use as an example of how I would like to be able
check for the value returned being a null.

Thus can you tell me how to solve my isuse?

Answers (4)