Class QueryableHelper
Extension methods for System.Linq.IQueryable<T>.
Inheritance
Inherited Members
Namespace: Kephas.Data.Linq
Assembly: Kephas.Data.dll
Syntax
public static class QueryableHelper
Methods
| Improve this Doc View SourceAnyAsync(IQueryable, CancellationToken)
Determines asynchronously whether a sequence contains any elements.
Declaration
public static Task<bool> AnyAsync(this IQueryable query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | A promise of a boolean value indicating whether a sequence contains any elements. |
AnyAsync<T>(IQueryable<T>, CancellationToken)
Determines asynchronously whether a sequence contains any elements.
Declaration
public static Task<bool> AnyAsync<T>(this IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | A promise of a boolean value indicating whether a sequence contains any elements. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
CountAsync(IQueryable, CancellationToken)
Returns the number of elements in a sequence.
Declaration
public static Task<int> CountAsync(this IQueryable query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | A promise of the number of elements in a sequence. |
CountAsync<T>(IQueryable<T>, CancellationToken)
Returns the number of elements in a sequence.
Declaration
public static Task<int> CountAsync<T>(this IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | A promise of the number of elements in a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
FirstAsync(IQueryable, CancellationToken)
Returns the first element of a sequence.
Declaration
public static Task<object> FirstAsync(this IQueryable query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the first element of a sequence. |
FirstAsync<T>(IQueryable<T>, Expression<Func<T, Boolean>>, CancellationToken)
Returns the first element of a sequence that satisfies a specified condition.
Declaration
public static Task<T> FirstAsync<T>(this IQueryable<T> query, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> | predicate | The condition to be satisfied. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the first element of a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
FirstAsync<T>(IQueryable<T>, CancellationToken)
Returns the first element of a sequence.
Declaration
public static Task<T> FirstAsync<T>(this IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the first element of a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
FirstOrDefaultAsync(IQueryable, CancellationToken)
Returns the first element of a sequence, or a default value, if the sequence contains no elements.
Declaration
public static Task<object> FirstOrDefaultAsync(this IQueryable query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the first element of a sequence. |
FirstOrDefaultAsync<T>(IQueryable<T>, Expression<Func<T, Boolean>>, CancellationToken)
Returns the first element of a sequence that satisfies a specified condition, or a default value, if no such element is found.
Declaration
public static Task<T> FirstOrDefaultAsync<T>(this IQueryable<T> query, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> | predicate | The condition to be satisfied. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the first element of a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
FirstOrDefaultAsync<T>(IQueryable<T>, CancellationToken)
Returns the first element of a sequence, or a default value, if the sequence contains no elements.
Declaration
public static Task<T> FirstOrDefaultAsync<T>(this IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the first element of a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
LongCountAsync(IQueryable, CancellationToken)
Returns a long that represents the number of elements in a sequence.
Declaration
public static Task<long> LongCountAsync(this IQueryable query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int64> | A promise of a long that represents the number of elements in a sequence. |
LongCountAsync<T>(IQueryable<T>, CancellationToken)
Returns a long that represents the number of elements in a sequence.
Declaration
public static Task<long> LongCountAsync<T>(this IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int64> | A promise of a long that represents the number of elements in a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
SingleAsync(IQueryable, CancellationToken)
Returns the single element of a sequence.
Declaration
public static Task<object> SingleAsync(this IQueryable query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the single element of a sequence. |
SingleAsync<T>(IQueryable<T>, Expression<Func<T, Boolean>>, CancellationToken)
Returns the single element of a sequence that satisfies a specified condition.
Declaration
public static Task<T> SingleAsync<T>(this IQueryable<T> query, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> | predicate | The condition to be satisfied. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the single element of a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
SingleAsync<T>(IQueryable<T>, CancellationToken)
Returns the single element of a sequence.
Declaration
public static Task<T> SingleAsync<T>(this IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the single element of a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
SingleOrDefaultAsync(IQueryable, CancellationToken)
Returns the single element of a sequence, or a default value, if the sequence contains no elements.
Declaration
public static Task<object> SingleOrDefaultAsync(this IQueryable query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the single element of a sequence. |
SingleOrDefaultAsync<T>(IQueryable<T>, Expression<Func<T, Boolean>>, CancellationToken)
Returns the single element of a sequence that satisfies a specified condition, or a default value, if no such element is found.
Declaration
public static Task<T> SingleOrDefaultAsync<T>(this IQueryable<T> query, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> | predicate | The condition to be satisfied. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the single element of a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
SingleOrDefaultAsync<T>(IQueryable<T>, CancellationToken)
Returns the single element of a sequence, or a default value, if the sequence contains no elements.
Declaration
public static Task<T> SingleOrDefaultAsync<T>(this IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A promise of the single element of a sequence. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
ToListAsync(IQueryable, CancellationToken)
Executes the query asynchronously and returns a list of items.
Declaration
public static Task<IList<object>> ToListAsync(this IQueryable query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IList<System.Object>> | A list of items. |
ToListAsync<T>(IQueryable<T>, CancellationToken)
Executes the query asynchronously and returns a list of items.
Declaration
public static Task<IList<T>> ToListAsync<T>(this IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Linq.IQueryable<T> | query | The query. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IList<T>> | A list of items. |
Type Parameters
Name | Description |
---|---|
T | The element type. |