/// <summary>
    /// Shows how to Select all records by Course, related to column CourseId
    /// </summary>
    private void SelectCourseEnrollmentInfoCollectionByCourseId()
    {
        int courseIdSample = 12;

        List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectCourseEnrollmentInfoCollectionByCourseId(courseIdSample);

        // Example 1:  you can optionally sort the collection in ascending order by your chosen field
        objCourseEnrollmentInfoCol.Sort(CourseEnrollmentInfo.ByCourseId);

        // Example 2:  to sort in descending order, add this line to the Sort code in Example 1
        objCourseEnrollmentInfoCol.Reverse();

        // Example 3:  directly bind to a GridView - for ASP.NET Web Forms
        // GridView grid = new GridView();
        // grid.DataSource = objCourseEnrollmentInfoCol;
        // grid.DataBind();

        // Example 4:  loop through all the CourseEnrollmentInfo(s)
        foreach (CourseEnrollmentInfo objCourseEnrollmentInfo in objCourseEnrollmentInfoCol)
        {
            int    enrollmentId = objCourseEnrollmentInfo.EnrollmentId;
            int    courseId     = objCourseEnrollmentInfo.CourseId;
            int    studentId    = objCourseEnrollmentInfo.StudentId;
            string comments     = objCourseEnrollmentInfo.Comments;

            // get the CourseEnrollmentInfo related to EnrollmentId.
            CourseEnrollmentInfo objCourseEnrollmentInfoRelatedToEnrollmentId = CourseEnrollmentInfo.SelectByPrimaryKey(enrollmentId);

            // get the Course related to CourseId.
            Course objCourseRelatedToCourseId = Course.SelectByPrimaryKey(courseId);

            // get the Student related to StudentId.
            Student objStudentRelatedToStudentId = Student.SelectByPrimaryKey(studentId);
        }
    }
    /// <summary>
    /// Shows how to Select all records by Course, related to column CourseId sorted by column name in either ascending or descending order.
    /// </summary>
    private void SelectCourseEnrollmentInfoCollectionByCourseIdWithSortExpression()
    {
        int    courseIdSample = 12;
        string sortBy         = "EnrollmentId"; // ascending order
        //string sortBy = "EnrollmentId desc"; // descending order

        List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectCourseEnrollmentInfoCollectionByCourseId(courseIdSample, sortBy);
    }