handling nullable datatypes when using typed dataset
Posted on 2007-03-30
I have a typed DataSet as my Data Access Layer.
In my BLL, I have the following static method:
public static Support GetJob(int Id)
SupportDAL.SupportRequestDataTable dt = sAdapter.GetJob(Id);
Support s = new Support();
if (dt.Count > 0)
SupportDAL.SupportRequestRow r = dt;
s.AssignedTo = r.IsAssignedToNull() ? <what goes here>: Convert.ToInt16(r.AssignedTo);
// and more stuff goes here
s.AssignedTo is of type short and is nullable.
Since my database has null values for "AssignedTo", I need to use IsAssignedToNull(). I am confused on what I should assign to s.AssignedTo if the value is in fact null in the database. see the <what goes here> section in my code.