Exemplo n.º 1
0
 private T GetFirst <T>(SqlCommand command, SqlRowParser <T> parser)
 {
     using (var reader = command.ExecuteReader())
     {
         return(reader.Read() ? parser.Parse(reader, 0) : default(T));
     }
 }
Exemplo n.º 2
0
 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)
 };
Exemplo n.º 3
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);
            }
        }