As John Skeet said, the SqlDataReader class has a GetTimeSpan method.
conn = new SqlConnection(blablabla); conn.Open(); string sql = "SELECT * FROM MyTable"; SqlCommand sqlCommand = new SqlCommand(sql, conn); reader = sqlCommand.ExecuteReader(); while (reader.Read()) { MyVeryOwnModel mvom = new MyVeryOwnModel(); mvom.timeStart = reader.GetTimeSpan(reader.GetOrdinal("column_time_start")); mvom.timeEnd = reader.GetTimeSpan(reader.GetOrdinal("column_time_end")); } reader.Close();
source share