public List<TrackCourse> GetByTrack(int id) { List<TrackCourse> list = null; DataProvider.ExecuteCmd(GetConnection, "dbo.TrackCourses_SelectByTrackID", inputParamMapper: delegate (SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@TracksId", id); }, map: delegate (IDataReader reader, short set) { TrackCourse s = new TrackCourse(); int startingIndex = 0; s.CourseId = reader.GetSafeInt32(startingIndex++); s.Order = reader.GetSafeInt32(startingIndex++); if (list == null) { list = new List<TrackCourse>(); } list.Add(s); } ); return list; }
public TrackCourse Get(int id) { TrackCourse s = null; DataProvider.ExecuteCmd(GetConnection, "dbo.TrackCourses_SelectById", inputParamMapper: delegate (SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@TracksId", id); }, map: delegate (IDataReader reader, short set) { s = new TrackCourse(); int startingIndex = 0; s.CourseId = reader.GetSafeInt32(startingIndex++); s.Order = reader.GetSafeInt32(startingIndex++); } ); return s; }
public Track Get(int id) { Track item = null; TrackCourse getTrackCourse = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Tracks_SelectById" , inputParamMapper: delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Id", id); //model binding }, map: delegate(IDataReader reader, short set) { if (set == 0) { item = new Track(); int startingIndex = 0; //startingOrdinal item.Id = reader.GetSafeInt32(startingIndex++); item.Name = reader.GetSafeString(startingIndex++); item.Format = reader.GetSafeInt32(startingIndex++); item.ExpectedOutcome = reader.GetSafeString(startingIndex++); item.Cost = reader.GetSafeInt32(startingIndex++); item.Description = reader.GetSafeString(startingIndex++); } else if (set == 1 && item != null) { getTrackCourse = new TrackCourse(); int startingIndex = 0; getTrackCourse.CourseId = reader.GetSafeInt32(startingIndex++); getTrackCourse.Order = reader.GetSafeInt32(startingIndex++); getTrackCourse.CourseName = reader.GetSafeString(startingIndex); if (item.TracksCourses == null) { item.TracksCourses = new List<TrackCourse>(); } if( item.CourseIds == null) { item.CourseIds = new List<int>(); } item.TracksCourses.Add(getTrackCourse); item.CourseIds.Add(getTrackCourse.CourseId); } else if (set == 2 && item != null) { BaseCourse prereq = new BaseCourse(); int startingIndex = 0; prereq.CourseName = reader.GetSafeString(startingIndex++); prereq.Id = reader.GetSafeInt32(startingIndex); if (item.Prerequisites == null) { item.Prerequisites = new List<BaseCourse>(); } item.Prerequisites.Add(prereq); } }); return item; }
public List<Track> GetTrackList() { List<Track> list = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Tracks_SelectAll" , inputParamMapper: null , map: delegate(IDataReader reader, short set) { if (set == 0) { Track ct = new Track(); int startingIndex = 0; ct.Id = reader.GetSafeInt32(startingIndex++); ct.Name = reader.GetSafeString(startingIndex++); ct.Format = reader.GetSafeInt32(startingIndex++); ct.ExpectedOutcome = reader.GetSafeString(startingIndex++); ct.Cost = reader.GetSafeInt32(startingIndex++); ct.Description = reader.GetSafeString(startingIndex++); if (list == null) { list = new List<Track>(); } list.Add(ct); } else if (set == 1 && list != null) { TrackCourse item = new TrackCourse(); int startingIndex = 0; var TracksId = reader.GetSafeInt32(startingIndex++); item.CourseId = reader.GetSafeInt32(startingIndex++); item.Order = reader.GetSafeInt32(startingIndex++); item.CourseName = reader.GetSafeString(startingIndex++); foreach (var track in list) { if (track.Id == TracksId) { if (track.TracksCourses == null) { track.TracksCourses = new List<TrackCourse>(); } track.TracksCourses.Add(item); } } } else if (set == 2 && list != null) { BaseCourse prereq = new BaseCourse(); int startingIndex = 0; prereq.TracksId = reader.GetSafeInt32(startingIndex++); prereq.CourseName = reader.GetSafeString(startingIndex++); prereq.Id = reader.GetSafeInt32(startingIndex); foreach (var track in list) { if (track.Id == prereq.TracksId) { if (track.Prerequisites == null) { track.Prerequisites = new List<BaseCourse>(); } track.Prerequisites.Add(prereq); } } } }); return list; }