FluorineFx.NET

Using Pageable Recordsets

Pageable recordset is a feature of the Actionscript Recordset Class which allows you to divide the result of a query into different pages and decide how to fetch the returned rows.

1. To activate the pageable recordset feature, the service method must be marked with a FluorineFx.PageSizeAttribute attribute.

Available constructors:

PageSizeAttribute(int pageSize)
PageSizeAttribute(int pageSize, int offset, int limit)

where

pagesize - number of records requested each time
offset - the offset of the first row to return
limit - the maximum number of rows to return

 The method fetching the recordset must have only simple parameter types

Use FluorineFx.PagingContext.Current to get the current offset and limit values.

2. A [methodName]Count method must be available to get the total record count. The return type is "int".

 The parameters of the [methodName]Count method must match the parameters of the method from (1)

Sample service class:

public class DataService
{

    [PageSize(10)]
    public object GetRecords(string filter)
    {
        ...
        int offset = PagingContext.Current.Offset;
        int limit = PagingContext.Current.Limit;
        string query = string.Format("SELECT * FROM table WHERE Column LIKE '{0}%' LIMIT {1}, {2}", filter, offset, limit);
        MySqlDataAdapter adapter = new MySqlDataAdapter(query, connection);
        DataTable dataTable = new DataTable();
        adapter.Fill(dataTable);
        return dataTable;
    }

    public int GetRecordsCount(string filter)
    {
        ...
        MySqlCommand command = connection.CreateCommand();
        command.CommandText = string.Format("SELECT COUNT(*) FROM table WHERE Column LIKE '{0}%'", filter);
        object result = command.ExecuteScalar();
        return System.Convert.ToInt32(result);
    }
}