private T GetFirst <T>(SqlCommand command, SqlRowParser <T> parser) { using (var reader = command.ExecuteReader()) { return(reader.Read() ? parser.Parse(reader, 0) : default(T)); } }
public Enrollment Parse(SqlDataReader reader, int currentIndex) => new Enrollment { IdEnrollment = int.Parse(reader["IdEnrollment"].ToString()), Semester = int.Parse(reader["Semester"].ToString()), StartDate = DateTime.Parse(reader["StartDate"].ToString()), IdStudyNavigation = _studiesSqlRowParser.Parse(reader, 0) };
private IEnumerable <T> GetAll <T>(SqlCommand command, SqlRowParser <T> parser) { using (var reader = command.ExecuteReader()) { var result = new List <T>(); while (reader.Read()) { var item = parser.Parse(reader, result.Count); result.Add(item); } return(result); } }