Skip to content

CursorQueryDTO Custom implementation

linvi edited this page Jun 7, 2015 · 1 revision

This is quite simple. You just need to specify an array with a JsonProperty attribute specifying the json name of the object received.

Here is how the IdsCursorQueryResultDTO has been implemented.

public class IdsCursorQueryResultDTO : BaseCursorQueryDTO<long>, IIdsCursorQueryResultDTO
{
    private long[] _ids;

    [JsonProperty("ids")]
    public long[] Ids
    {
        get { return _ids ?? new long[0]; }
        set
        {
            _ids = value;
            Results = value;
        }
    }

    public override int GetNumberOfObjectRetrieved()
    {
        return Ids.Length;
    }
}