I have a lot of classes for data-access in one of my projects, but these classes are becoming extremely bulky because of the code that retrieves the data from the data readers.
My code generally looks like this:
// Execute the data reader
using (DbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
obj = this.FillDataReader(reader);
objlist.Add(obj);
}
}
internal SomeObject FillDataReader(IDataReader dr)
{
SomeObject obj = new SomeObject ();
if (!dr.IsDBNull(dr.GetOrdinal("objectID")))
{
obj.ID = dr.GetInt32(dr.GetOrdinal("objectID"));
}
return obj;
}
Some of the Fill methods easily hit 400+ lines, so is there a decent way to separate these out? Would partial classes be acceptable? In an ideal world, I would be using an ORM, but unfortunately I can't afford the time to learn how to use one.