internal static Competition ReadCompetition(SqlDataReader reader) { var comp = new Competition { CompetitionTitle = ReadObject(reader, "CompTitle", ""), Details = ReadObject(reader, "CompDetails", ""), Description = ReadObject(reader, "Description", ""), IsRegistered = ReadObject(reader, "IsRegistered", 0) == 1 }; var id = ReadObjectOrNull <int>(reader, "ID"); if (id.HasValue) { comp.Id = id.Value; } var startDate = ReadObjectOrNull <DateTime>(reader, "StartDate"); var endDate = ReadObjectOrNull <DateTime>(reader, "EndDate"); if (startDate.HasValue) { comp.StartDate = startDate.Value; } if (endDate.HasValue) { comp.EndDate = endDate.Value; } comp.Location = ReadLocation(reader); foreach (var rule in ReadRules(reader)) { comp.AddRule(rule); } foreach (var category in ReadCategories(reader)) { comp.AddCategory(category); } foreach (var type in ReadTypes(reader)) { comp.AddType(type); } return(comp); }