Monday, March 10, 2014

LINQ Queries OR SQL checking Nothing or Null Values

You need to check if it's Nothing first and use the AndAlso keyword to stop it from evaluating the latter statement. Also, when checking if the and object is null, you should use the Is or IsNotoperator rather than =. This should work

Dim otherRecords As List(Of Objects) = listOf.Where(Function(x) _
                                                        (x.ID_NUM = newID) AndAlso _
                                                        (x.Codes IsNot Nothing) AndAlso _
                                                        (x.Codes.Contains(ddlPrimaryCode.SelectedItem.Text.Trim()))).ToList()

No comments:

Containerization Fundamentals: An Informational Guide for US Business Owners

Containerization Fundamentals: An Informational Guide for US Business Owners Introduction to Containerization Definition and Basic C...