I\'m using a SQLdatareader to build POCOs from a database. The code works except when it encounters a null value in the database. For example, if the FirstName column in the
As an addition to the answer by marc_s, you can use a more generic extension method to get values from the SqlDataReader:
public static T SafeGet(this SqlDataReader reader, int col) { return reader.IsDBNull(col) ? default(T) : reader.GetFieldValue(col); }