[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1781
  • Last Modified:

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

0
ekenman
Asked:
ekenman
1 Solution
 
nmarunCommented:
try this:

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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now