Beispiel #1
0
    /// <summary>
    /// Shows how to Select all records.  It also shows how to sort, bind, and loop through records.
    /// </summary>
    private void SelectAll()
    {
        // select all records
        List <RoleMaster> objRoleMasterCol = RoleMaster.SelectAll();

        // Example 1:  you can optionally sort the collection in ascending order by your chosen field
        objRoleMasterCol.Sort(RoleMaster.ByRoleDescription);

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

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

        // Example 4:  loop through all the RoleMaster(s)
        foreach (RoleMaster objRoleMaster in objRoleMasterCol)
        {
            int      roleId          = objRoleMaster.RoleId;
            string   roleDescription = objRoleMaster.RoleDescription;
            DateTime createdOn       = objRoleMaster.CreatedOn;
            string   createdBy       = objRoleMaster.CreatedBy;
            DateTime?modifiedOn      = objRoleMaster.ModifiedOn;
            string   modifiedBy      = objRoleMaster.ModifiedBy;
        }
    }
Beispiel #2
0
    /// <summary>
    /// Shows how to Select all records sorted by column name in either ascending or descending order.
    /// </summary>
    private void SelectAllWithSortExpression()
    {
        // select all records sorted by RoleId in ascending order
        string sortBy = "RoleId"; // ascending order
        //string sortBy = "RoleId desc"; // descending order

        List <RoleMaster> objRoleMasterCol = RoleMaster.SelectAll(sortBy);
    }