Data Access has been discontinued. Please refer to this page for more information.

Null Comparison Expression

A null value in the data source indicates that the value is unknown. You can check for null values so that certain calculations or comparisons are only performed on rows that have valid, or non-null, data. CLR null semantics, however, may differ from the null semantics of the data source.

The following LINQ query is expressed in the CLR, but it is executed in the data source. Because there is no guarantee that CLR semantics will be honored at the data source, the expected behavior is indeterminate.

using ( FluentModel dbContext = new FluentModel() )
{
   IQueryable<string> productNames = from product in dbContext.Products
                                     join category in dbContext.Categories on product.CategoryID 
                                     equals category.CategoryID
                                     where category.Description == null
                                     select product.ProductName;
   foreach ( string productName in productNames )
   {
       Console.WriteLine( productName );
   }
}
Using dbContext As New FluentModel()
 Dim productNames As IQueryable(Of String) = _
             From product In dbContext.Products
             Join category In dbContext.Categories On product.CategoryID 
             Equals category.CategoryID
             Where category.Description Is Nothing
             Select product.ProductName
 For Each productName As String In productNames
  Console.WriteLine(productName)
 Next productName
End Using

See Also