PagingParams

Defines a data transfer object used to pass paging parameters for queries.

Description

The PagingParams class allows you to create data transfer objects used to pass paging parameters for queries.

Important points

  • A page is defined by two parameters:
    • skip: number of items to skip.
    • take: number of items to return in a page.
  • Additionally, the optional total parameter defines whether to return the total number of items or not.
  • However, not all implementations support the total parameter, because its generation may lead to severe performance implications.

Constructors

Creates a new instance and sets its values.

public PagingParams(object skip, object take, object total = null)

  • skip: object - the number of items to skip.
  • take: object - the number of items to return.
  • total: bool - true to return the total number of items.

Properties

Skip

The number of items to skip.

public long Skip [ get, set ]

Take

The number of items to return.

public long Take [ get, set ]

Total

The flag to return the total number of items.

public bool Total [ get, set ]

Instance methods

GetSkip

Gets the number of items to skip.

public long GetSkip(long minSkip = 0)

  • minSkip: long - the minimum number of items to skip.
  • returns: long - the number of items to skip.

GetTake

Gets the number of items to return in a page.

public long GetTake(long maxTake)

  • maxTake: long - the maximum number of items to return.
  • returns: long - the number of items to return.

Static methods

FromMap

Creates a new PagingParams and sets it parameters from the specified map

public static PagingParams FromMap(AnyValueMap map)

  • map: AnyValueMap - a AnyValueMap or StringValueMap to initialize this PagingParams
  • returns: PagingParams - a newly created PagingParams.

FromTuples

Creates a new PagingParams from a list of key-value pairs called tuples.

public static PagingParams FromTuples(params object[] tuples)

  • tuples: object[] - a list of values where odd elements are keys and the following even elements are values
  • returns: PagingParams - a newly created PagingParams.

FromValue

Converts specified value into PagingParams.

public static PagingParams FromValue(object value)

  • value: object - value to be converted
  • returns: PagingParams - a newly created PagingParams.

Examples

var filter = FilterParams.FromTuples("type", "Type1");
var paging = new PagingParams(0, 100);

myDataClient.GetDataByFilter(filter, paging);