Handling null values with LINQ to Entity

I'm quite new to LINQ and Entity Framework so bear with me..`

I have a procedure that search for customers and resturns a list for a JQuery autocomplete field. It works fine exept when there are null values in the first och last name fields.

How do I check for null values so I can return the first or last name if the other is empty?

Thanks in advance

/Tomas

Public Function SearchCustomer(Byval q as String, Optional ByVal limit as Integer = 10) as ActionResult
Dim retvalue = (From c in _db.Customer
                Where c.CustomerFirstName.StartWith(q) or c.CustomerLastName.StartWith(q)
                Select name = c.CustomerFirstName & " " & c.CustomerLastName, id = c.CustomerID).Take(limit).ToList
Return Json(retvalue)

Open in new window

ekenmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nmarunCommented:
try this:

              Dim retVal  = (From activity In  loaded.Descendants("Activity") _
    Select If(activity.Value,  "")).Take(3).ToList()
     
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ekenmanAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.