Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

how to check for NULL values?

$
0
0

I'm new to Entity Framework and I'm getting a null reference error that I'm not sure how to resolve.

In my DBContext class, in the onModelCreating method, I'm binding the database columns to the class that I am using.

My database column is called "cancelled_date" and my class property is "CancelledDate". My query that is returning the data has some records with null values in this column.

Here's my code snippet in the onModelCreating method:

...

entity.Property(e => e.CancelledDate)
.HasColumnName("cancelled_date")
.HasColumnType("datetime");

...

What attribute do I need to add to check for nulls? I tried putting a try/catch around this, but that did not work. 

Any suggestions? Thanks!


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>