get relationship object (object to object)
public List GetUserCourses(int userID)
{
List userCourses = new List();
try
{
TblUserCourseCollection tblUserCourses = new TblUserCourseCollection()
.Where(TblUserCourse.Columns.IntUserId, userID)
.Load();
foreach (TblUserCourse tblUserCourse in tblUserCourses)
{
if (tblUserCourse.TblCourse.BitIsActive)
{
Course course = new Course();
course.CourseId = tblUserCourse.IntCourseId;
course.Code = tblUserCourse.TblCourse.VcCode;
course.Description = tblUserCourse.TblCourse.VcDescription;
course.IsActive = tblUserCourse.TblCourse.BitIsActive;
course.Name = tblUserCourse.TblCourse.VcName;
userCourses.Add(course);
course.Lessons = new List();
if (tblUserCourse.TblCourse.TblLessonRecords != null)
{
foreach (TblLesson tblLesson in tblUserCourse.TblCourse.TblLessonRecords)
{
Lesson lesson = new Lesson();
lesson.LessonId = tblLesson.IntLessonId;
lesson.Name = tblLesson.VcName;
course.Lessons.Add(lesson);
}
}
}
}
}
catch (Exception ex)
{
ELearning.ErrorLogger.Error.WriteErrorLog(ex);
}
return userCourses;
}
0 Response to "get relationship object (object to object)"
Post a Comment