DBNull.Value works on DataTable rows, I'm not sure with SqlDataReader:
bool isNull = objSqlDataReader.GetOrdinal("EFID") == DBNull.Value;
If you use SqlDataReader's GetSqlInt32,GetSqlDateTime, etc for example, they are null-aware out-of-the-box.
Instead of unboxing:
emissiondata.ID = (int)objSqlDataReader["EFID"];
You do this instead:
SqlInt32 emissionId = objSqlDataReader.GetSqlInt32(emissionIdOrdinal);
Then you can test for null directly:
if (emissionId.IsNull) ...
However, those methods need the column's ordinal to access value. You can setup those ordinals before your loop
int emissionIdOrdinal = rdr.GetOrdinal("EFID");
But if you really want C#'s null, you make a helper function for it instead:
public static int? ToNullable(this SqlInt32 value)
{
return value.IsNull ? (int?) null : value.Value;
}
To access it with your nullable variable:
int? emissionId = objSqlDataReader.GetSqlInt32(emissionIdOrdinal).ToNullable();
You can now test null directly:
if (emissionId == null)
An advice, try to change your class' properties to nullable types, precluding the need for you to use another variable:
public int? ID { get; set; }
public int? Map { get; set; }
public int? TypeID { get; set; }
Final code:
data= new data();
emissiondata.ID = objSqlDataReader.GetSqlInt32(emissionIdOrdinal).ToNullable();
emissiondata.Map = objSqlDataReader.GetSqlInt32(emissionMapOrdinal).ToNullable();