Table of Contents

Class CardQuery

Namespace
TcgDex.Querying
Assembly
TcgDex.CSharpSdk.dll

Builds a card query from strongly-typed predicates.

public sealed class CardQuery

Inheritance

Inherited Members

Examples

CardQuery query = new CardQuery()
    .Where(c => c.Name.Contains("Pikachu"))
    .Where(c => c.Hp > 100)
    .OrderByDescending(c => c.Name)
    .Page(1, 50);

IReadOnlyList<CardBrief> cards = await client.Cards.ListAsync(query, cancellationToken);

Remarks

Every method returns a new instance, so a partially-built query can be shared and specialised without one caller's additions leaking into another's.

This is deliberately not an System.Linq.IQueryable`1. The API supports only the operators in TcgDex.Querying.QueryOperator, so an IQueryable would have to throw for most of LINQ — a partial implementation that fails at runtime instead of at the call site. A dedicated builder makes the supported surface explicit.

Constructors

CardQuery()

Creates an unfiltered query.

public CardQuery()

Methods

OrderBy<TKey>(Expression<Func<Card, TKey>>)

Sorts ascending by a field.

public CardQuery OrderBy<TKey>(Expression<Func<Card, TKey>> selector)

Parameters

selector Expression<Func<Card, TKey>>

The property to sort on.

Returns

CardQuery

A new query with this ordering.

Type Parameters

TKey

OrderByDescending<TKey>(Expression<Func<Card, TKey>>)

Sorts descending by a field.

public CardQuery OrderByDescending<TKey>(Expression<Func<Card, TKey>> selector)

Parameters

selector Expression<Func<Card, TKey>>

The property to sort on.

Returns

CardQuery

A new query with this ordering.

Type Parameters

TKey

Page(int, int)

Requests a single page of results.

public CardQuery Page(int page, int itemsPerPage)

Parameters

page int

The 1-based page number.

itemsPerPage int

How many results per page.

Returns

CardQuery

A new query limited to that page.

Remarks

The API exposes no total count and sends no pagination headers, so the number of pages cannot be known up front — read pages until one comes back shorter than itemsPerPage.

Exceptions

ArgumentOutOfRangeException

Either argument is less than one.

ToQueryString()

Renders the query as a URL query string, without a leading ?.

public string ToQueryString()

Returns

string

The query string, or empty when nothing has been specified.

Remarks

Filters are top-level parameters. There is no q parameter in this API, despite what some older documentation suggests.

Where(Expression<Func<Card, bool>>)

Adds a filter. Multiple calls are combined with AND, matching the API's treatment of repeated parameters.

public CardQuery Where(Expression<Func<Card, bool>> predicate)

Parameters

predicate Expression<Func<Card, bool>>

The condition to translate.

Returns

CardQuery

A new query including this filter.

Exceptions

NotSupportedException

The predicate has no equivalent in the API's filter syntax. The message names the offending expression and lists the supported forms.