Exemple #1
0
    /// <summary>
    /// Shows how to get a specific number of sorted records, starting from an index by the related Field Name.  The total number of records are also retrieved when using the SelectSkipAndTake() method.
    /// For example, if there are 200 records, take only 10 records (numberOfRecordsToRetrieve), starting from the first index (startRetrievalFromRecordIndex = 0)
    /// The example below uses some variables, here are their definitions:
    /// totalRecordCount - total number of records if you were to retrieve everything
    /// startRetrievalFromRecordIndex - the index to start taking records from. Zero (0) E.g. If you want to skip the first 20 records, then assign 19 here.
    /// numberOfRecordsToRetrieve - take n records starting from the startRetrievalFromRecordIndex
    /// sortBy - to sort in Ascending order by Field Name, just assign just the Field Name, do not pass 'asc'
    /// sortBy - to sort in Descending order by Field Name, use the Field Name, a space and the word 'desc'
    /// </summary>
    private void SelectSkipAndTakeByCourseName()
    {
        int    startRetrievalFromRecordIndex = 0;
        int    numberOfRecordsToRetrieve     = 10;
        string sortBy = "EnrollmentId";
        //string sortBy = "EnrollmentId desc";

        // 1. select a specific number of sorted records with a CourseName = 12
        // starting from the index you specify
        List <CourseEnrollment> objCourseEnrollmentCol = CourseEnrollment.SelectSkipAndTakeByCourseName(numberOfRecordsToRetrieve, startRetrievalFromRecordIndex, sortBy, 12);

        // to use objCourseEnrollmentCol please see the SelectAll() method examples
        // No need for Examples 1 and 2 because the Collection here is already sorted
        // Example 3:  directly bind to a GridView - for ASP.NET Web Forms
        // Example 4:  loop through all the CourseEnrollment(s).  The example above will only loop for 10 items.
    }