Skip to content

DmQuery`1 ​

Namespace: MJCZone.DapperMatic.Dml

Assembly: MJCZone.DapperMatic

Summary ​

A query of a model's rows: one <c>SELECT</c>, built up by <c>Where</c>, <c>OrderBy</c>, <c>Skip</c>, <c>Take</c>, <c>Distinct</c> and <c>Select</c>, and run by one of the <c>...Async</c> methods.

sealed public

Contents ​

Methods (39)

Methods ​

MethodSummary
Where
WhereExists
WhereNotExists
WhereExists
WhereNotExists
OrderBy
OrderByDescending
ThenBy
ThenByDescending
SkipSkips rows.
TakeReturns at most a number of rows.
DistinctReturns each distinct row once.
IncludeDeletedReads deleted rows of models with a <c>[DmSoftDelete]</c> too: the query's, its relation...
OnlyDeletedReads only the query's deleted rows, with its relations' and includes' rows that are not deleted.
Include
Include
Select
Join
LeftJoin
GroupBy
GroupBy
AfterContinues from a page: CancellationToken) then reads the rows after the cursor, in the same order....
ToPageAsyncReads a page of rows in keyset order: the query's own ordering columns, then the model's key, so tha...
ToListAsyncReads the rows.
FirstAsyncReads the first row: in the query's order, or in key order if it has none.
SingleAsyncReads the one row the query returns.
CountAsyncCounts the rows the query returns.
ExistsAsyncTells whether the query returns any rows.
SumAsyncAdds up a value over the rows the query returns, skipping NULLs.
MinAsyncFinds the least value over the rows the query returns.
MaxAsyncFinds the greatest value over the rows the query returns.
AverageAsyncAverages a number over the rows the query returns, skipping NULLs, with a fraction even for integers...
AverageAsyncAverages a number over the rows the query returns, skipping NULLs, with a fraction even for integers...
AverageAsyncAverages a number over the rows the query returns, skipping NULLs, with a fraction even for integers...
ToSqlWrites the SQL that CancellationToken) runs, without running it....
GetType
ToString
Equals
GetHashCode

Where ​

csharp
Where()

WhereExists ​

csharp
WhereExists()

WhereNotExists ​

csharp
WhereNotExists()

WhereExists ​

csharp
WhereExists()

WhereNotExists ​

csharp
WhereNotExists()

OrderBy ​

csharp
OrderBy()

OrderByDescending ​

csharp
OrderByDescending()

ThenBy ​

csharp
ThenBy()

ThenByDescending ​

csharp
ThenByDescending()

Skip ​

Skips rows.

csharp
DmQuery&lt;T&gt; Skip(int count)

Parameters ​

  • count (int) - The number of rows to skip.

Returns ​

Type: DmQuery<T>

The query.

Take ​

Returns at most a number of rows.

csharp
DmQuery&lt;T&gt; Take(int count)

Parameters ​

  • count (int) - The most rows to return.

Returns ​

Type: DmQuery<T>

The query.

Distinct ​

Returns each distinct row once.

csharp
DmQuery&lt;T&gt; Distinct()

Returns ​

Type: DmQuery<T>

The query.

IncludeDeleted ​

Reads deleted rows of models with a <c>[DmSoftDelete]</c> too: the query's, its relations' and its includes'.

csharp
DmQuery&lt;T&gt; IncludeDeleted()

Returns ​

Type: DmQuery<T>

The query.

OnlyDeleted ​

Reads only the query's deleted rows, with its relations' and includes' rows that are not deleted.

csharp
DmQuery&lt;T&gt; OnlyDeleted()

Returns ​

Type: DmQuery<T>

The query.

Include ​

csharp
Include()

Include ​

csharp
Include()

Select ​

csharp
Select()

Join ​

csharp
Join()

LeftJoin ​

csharp
LeftJoin()

GroupBy ​

csharp
GroupBy()

GroupBy ​

csharp
GroupBy()

After ​

Continues from a page: CancellationToken) then reads the rows after the cursor, in the same order.

csharp
DmQuery&lt;T&gt; After(string cursor)

Parameters ​

  • cursor (string) - , or one the web API gave; null for the first page.

Returns ​

Type: DmQuery<T>

The query.

ToPageAsync ​

Reads a page of rows in keyset order: the query's own ordering columns, then the model's key, so that pages never skip or repeat a row however deep they go; from the cursor String) gives, or the start.

csharp
Task&lt;DmPage&lt;T&gt;&gt; ToPageAsync(
    int size,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • size (int) - The most rows the page holds.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<DmPage<T>>

The rows, and the cursor of the next page: null when this one is not full.

ToListAsync ​

Reads the rows.

csharp
Task&lt;List&lt;T&gt;&gt; ToListAsync(
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;List&lt;T&gt;&gt;

The rows.

FirstAsync ​

Reads the first row: in the query's order, or in key order if it has none.

csharp
Task&lt;T?&gt; FirstAsync(IDbTransaction tx, CancellationToken cancellationToken)

Parameters ​

  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;T?&gt;

The row, or null if there is none.

SingleAsync ​

Reads the one row the query returns.

csharp
Task&lt;T?&gt; SingleAsync(IDbTransaction tx, CancellationToken cancellationToken)

Parameters ​

  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;T?&gt;

The row, or null if there is none.

CountAsync ​

Counts the rows the query returns.

csharp
Task&lt;long&gt; CountAsync(IDbTransaction tx, CancellationToken cancellationToken)

Parameters ​

  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;long&gt;

The number of rows.

ExistsAsync ​

Tells whether the query returns any rows.

csharp
Task&lt;bool&gt; ExistsAsync(IDbTransaction tx, CancellationToken cancellationToken)

Parameters ​

  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;bool&gt;

True if it does.

SumAsync ​

Adds up a value over the rows the query returns, skipping NULLs.

csharp
Task&lt;TValue&gt; SumAsync(
    Func{`0 selector,
    ``0}} tx,
    IDbTransaction cancellationToken)

Parameters ​

  • selector (Func{`0) - .
  • tx (``0}}) - The transaction to use, or null.
  • cancellationToken (IDbTransaction) - The cancellation token.

Returns ​

Type: Task&lt;TValue&gt;

The sum: 0 if there are no rows, as in LINQ.

MinAsync ​

Finds the least value over the rows the query returns.

csharp
Task&lt;TValue&gt; MinAsync(
    Func{`0 selector,
    ``0}} tx,
    IDbTransaction cancellationToken)

Parameters ​

  • selector (Func{`0) - The value.
  • tx (``0}}) - The transaction to use, or null.
  • cancellationToken (IDbTransaction) - The cancellation token.

Returns ​

Type: Task&lt;TValue&gt;

The least value; null if there are no rows and the value can be null.

MaxAsync ​

Finds the greatest value over the rows the query returns.

csharp
Task&lt;TValue&gt; MaxAsync(
    Func{`0 selector,
    ``0}} tx,
    IDbTransaction cancellationToken)

Parameters ​

  • selector (Func{`0) - The value.
  • tx (``0}}) - The transaction to use, or null.
  • cancellationToken (IDbTransaction) - The cancellation token.

Returns ​

Type: Task&lt;TValue&gt;

The greatest value; null if there are no rows and the value can be null.

AverageAsync ​

Averages a number over the rows the query returns, skipping NULLs, with a fraction even for integers.

csharp
Task&lt;Nullable&lt;double&gt;&gt; AverageAsync(
    Func{`0 selector,
    ``0}} tx,
    IDbTransaction cancellationToken)

Parameters ​

  • selector (Func{`0) - The number.
  • tx (``0}}) - The transaction to use, or null.
  • cancellationToken (IDbTransaction) - The cancellation token.

Returns ​

Type: Task&lt;Nullable&lt;double&gt;&gt;

The average, or null if there are no values.

AverageAsync ​

Averages a number over the rows the query returns, skipping NULLs, with a fraction even for integers.

csharp
Task&lt;Nullable&lt;double&gt;&gt; AverageAsync(
    Func{`0 selector,
    ``0}} tx,
    IDbTransaction cancellationToken)

Parameters ​

  • selector (Func{`0) - The number.
  • tx (``0}}) - The transaction to use, or null.
  • cancellationToken (IDbTransaction) - The cancellation token.

Returns ​

Type: Task&lt;Nullable&lt;double&gt;&gt;

The average, or null if there are no values.

AverageAsync ​

Averages a number over the rows the query returns, skipping NULLs, with a fraction even for integers.

csharp
Task&lt;Nullable&lt;double&gt;&gt; AverageAsync(
    Func{`0 selector,
    ``0}} tx,
    IDbTransaction cancellationToken)

Parameters ​

  • selector (Func{`0) - The number.
  • tx (``0}}) - The transaction to use, or null.
  • cancellationToken (IDbTransaction) - The cancellation token.

Returns ​

Type: Task&lt;Nullable&lt;double&gt;&gt;

The average, or null if there are no values.

ToSql ​

Writes the SQL that CancellationToken) runs, without running it.

csharp
DmStatement ToSql()

Returns ​

Type: DmStatement

The SQL and its parameters.

GetType ​

csharp
GetType()

ToString ​

csharp
ToString()

Equals ​

csharp
Equals()

GetHashCode ​

csharp
GetHashCode()