DbSqlQuery<TEntity> Class

Definition

Represents a SQL query for entities that is created from a DbContext and is executed using the connection from that context. Instances of this class are obtained from the DbSet<TEntity> instance for the entity type. The query is not executed when this object is created; it is executed each time it is enumerated, for example by using foreach. SQL queries for non-entities are created using SqlQuery<TElement>(String, Object[]). See DbSqlQuery for a non-generic version of this class.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", Justification="FxCop rule is wrong; Db is not an abbreviation for data base.", MessageId="Db")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification="Name is intentional")]
public class DbSqlQuery<TEntity> : System.Data.Entity.Infrastructure.DbRawSqlQuery<TEntity> where TEntity : class
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public class DbSqlQuery<TEntity> : System.Data.Entity.Infrastructure.DbRawSqlQuery<TEntity> where TEntity : class
type DbSqlQuery<'Entity (requires 'Entity : null)> = class
    inherit DbRawSqlQuery<'Entity (requires 'Entity : null)>
Public Class DbSqlQuery(Of TEntity)
Inherits DbRawSqlQuery(Of TEntity)

Type Parameters

TEntity

The type of entities returned by the query.

Inheritance
DbRawSqlQuery<TEntity>
DbSqlQuery<TEntity>
Inheritance
DbSqlQuery<TEntity>
Attributes

Constructors

DbSqlQuery<TEntity>()

Creates an instance of a DbSqlQuery<TEntity> when called from the constructor of a derived type that will be used as a test double for SqlQuery(String, Object[]). Methods and properties that will be used by the test double must be implemented by the test double except AsNoTracking and AsStreaming where the default implementation is a no-op.

Methods

AllAsync(Func<TElement,Boolean>)

Asynchronously determines whether all the elements of the query satisfy a condition.

(Inherited from DbRawSqlQuery<TElement>)
AllAsync(Func<TElement,Boolean>, CancellationToken)

Asynchronously determines whether all the elements of the query satisfy a condition.

(Inherited from DbRawSqlQuery<TElement>)
AnyAsync()

Asynchronously determines whether the query contains any elements.

(Inherited from DbRawSqlQuery<TElement>)
AnyAsync(CancellationToken)

Asynchronously determines whether the query contains any elements.

(Inherited from DbRawSqlQuery<TElement>)
AnyAsync(Func<TElement,Boolean>)

Asynchronously determines whether any element of the query satisfies a condition.

(Inherited from DbRawSqlQuery<TElement>)
AnyAsync(Func<TElement,Boolean>, CancellationToken)

Asynchronously determines whether any element of the query satisfies a condition.

(Inherited from DbRawSqlQuery<TElement>)
AsNoTracking()

Returns a new query where the entities returned will not be cached in the DbContext.

AsStreaming()
Obsolete.

Returns a new query that will stream the results instead of buffering.

AsStreaming()
Obsolete.

Returns a new query that will stream the results instead of buffering.

(Inherited from DbRawSqlQuery<TElement>)
ContainsAsync(TElement)

Asynchronously determines whether the query contains a specified element by using the default equality comparer.

(Inherited from DbRawSqlQuery<TElement>)
ContainsAsync(TElement, CancellationToken)

Asynchronously determines whether the query contains a specified element by using the default equality comparer.

(Inherited from DbRawSqlQuery<TElement>)
CountAsync()

Asynchronously returns the number of elements in the query.

(Inherited from DbRawSqlQuery<TElement>)
CountAsync(CancellationToken)

Asynchronously returns the number of elements in the query.

(Inherited from DbRawSqlQuery<TElement>)
CountAsync(Func<TElement,Boolean>)

Asynchronously returns the number of elements in the query that satisfy a condition.

(Inherited from DbRawSqlQuery<TElement>)
CountAsync(Func<TElement,Boolean>, CancellationToken)

Asynchronously returns the number of elements in the query that satisfy a condition.

(Inherited from DbRawSqlQuery<TElement>)
Equals(Object)

Determines whether the specified object is equal to the current object.

FirstAsync()

Asynchronously returns the first element of the query.

(Inherited from DbRawSqlQuery<TElement>)
FirstAsync(CancellationToken)

Asynchronously returns the first element of the query.

(Inherited from DbRawSqlQuery<TElement>)
FirstAsync(Func<TElement,Boolean>)

Asynchronously returns the first element of the query that satisfies a specified condition.

(Inherited from DbRawSqlQuery<TElement>)
FirstAsync(Func<TElement,Boolean>, CancellationToken)

Asynchronously returns the first element of the query that satisfies a specified condition.

(Inherited from DbRawSqlQuery<TElement>)
FirstOrDefaultAsync()

Asynchronously returns the first element of the query, or a default value if the the query result contains no elements.

(Inherited from DbRawSqlQuery<TElement>)
FirstOrDefaultAsync(CancellationToken)

Asynchronously returns the first element of the query, or a default value if the the query result contains no elements.

(Inherited from DbRawSqlQuery<TElement>)
FirstOrDefaultAsync(Func<TElement,Boolean>)

Asynchronously returns the first element of the query that satisfies a specified condition or a default value if no such element is found.

(Inherited from DbRawSqlQuery<TElement>)
FirstOrDefaultAsync(Func<TElement,Boolean>, CancellationToken)

Asynchronously returns the first element of the query that satisfies a specified condition or a default value if no such element is found.

(Inherited from DbRawSqlQuery<TElement>)
ForEachAsync(Action<TElement>)

Asynchronously enumerates the query results and performs the specified action on each element.

(Inherited from DbRawSqlQuery<TElement>)
ForEachAsync(Action<TElement>, CancellationToken)

Asynchronously enumerates the query results and performs the specified action on each element.

(Inherited from DbRawSqlQuery<TElement>)
GetEnumerator()

Executes the query and returns an enumerator for the elements.

GetEnumerator()

Returns an IEnumerator<T> which when enumerated will execute the SQL query against the database.

(Inherited from DbRawSqlQuery<TElement>)
GetHashCode()

Serves as the default hash function.

GetType()

Gets the Type of the current instance.

LongCountAsync()

Asynchronously returns an Int64 that represents the total number of elements in the query.

(Inherited from DbRawSqlQuery<TElement>)
LongCountAsync(CancellationToken)

Asynchronously returns an Int64 that represents the total number of elements in the query.

(Inherited from DbRawSqlQuery<TElement>)
LongCountAsync(Func<TElement,Boolean>)

Asynchronously returns an Int64 that represents the number of elements in the query that satisfy a condition.

(Inherited from DbRawSqlQuery<TElement>)
LongCountAsync(Func<TElement,Boolean>, CancellationToken)

Asynchronously returns an Int64 that represents the number of elements in the query that satisfy a condition.

(Inherited from DbRawSqlQuery<TElement>)
MaxAsync()

Asynchronously returns the maximum value of the query.

(Inherited from DbRawSqlQuery<TElement>)
MaxAsync(CancellationToken)

Asynchronously returns the maximum value of the query.

(Inherited from DbRawSqlQuery<TElement>)
MinAsync()

Asynchronously returns the minimum value of the query.

(Inherited from DbRawSqlQuery<TElement>)
MinAsync(CancellationToken)

Asynchronously returns the minimum value of the query.

(Inherited from DbRawSqlQuery<TElement>)
SingleAsync()

Asynchronously returns the only element of the query, and throws an exception if there is not exactly one element in the sequence.

(Inherited from DbRawSqlQuery<TElement>)
SingleAsync(CancellationToken)

Asynchronously returns the only element of the query, and throws an exception if there is not exactly one element in the sequence.

(Inherited from DbRawSqlQuery<TElement>)
SingleAsync(Func<TElement,Boolean>)

Asynchronously returns the only element of the query that satisfies a specified condition, and throws an exception if more than one such element exists.

(Inherited from DbRawSqlQuery<TElement>)
SingleAsync(Func<TElement,Boolean>, CancellationToken)

Asynchronously returns the only element of the query that satisfies a specified condition, and throws an exception if more than one such element exists.

(Inherited from DbRawSqlQuery<TElement>)
SingleOrDefaultAsync()

Asynchronously returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.

(Inherited from DbRawSqlQuery<TElement>)
SingleOrDefaultAsync(CancellationToken)

Asynchronously returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.

(Inherited from DbRawSqlQuery<TElement>)
SingleOrDefaultAsync(Func<TElement,Boolean>)

Asynchronously returns the only element of the query that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

(Inherited from DbRawSqlQuery<TElement>)
SingleOrDefaultAsync(Func<TElement,Boolean>, CancellationToken)

Asynchronously returns the only element of the query that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

(Inherited from DbRawSqlQuery<TElement>)
ToArrayAsync()

Creates an array from the query by enumerating it asynchronously.

(Inherited from DbRawSqlQuery<TElement>)
ToArrayAsync(CancellationToken)

Creates an array from the query by enumerating it asynchronously.

(Inherited from DbRawSqlQuery<TElement>)
ToDictionaryAsync<TKey,TResult>(Func<TElement,TKey>, Func<TElement,TResult>)

Creates a Dictionary<TKey,TValue> from the query by enumerating it asynchronously according to a specified key selector and an element selector function.

(Inherited from DbRawSqlQuery<TElement>)
ToDictionaryAsync<TKey,TResult>(Func<TElement,TKey>, Func<TElement,TResult>, CancellationToken)

Creates a Dictionary<TKey,TValue> from the query by enumerating it asynchronously according to a specified key selector and an element selector function.

(Inherited from DbRawSqlQuery<TElement>)
ToDictionaryAsync<TKey,TResult>(Func<TElement,TKey>, Func<TElement,TResult>, IEqualityComparer<TKey>)

Creates a Dictionary<TKey,TValue> from the query by enumerating it asynchronously according to a specified key selector function, a comparer, and an element selector function.

(Inherited from DbRawSqlQuery<TElement>)
ToDictionaryAsync<TKey,TResult>(Func<TElement,TKey>, Func<TElement,TResult>, IEqualityComparer<TKey>, CancellationToken)

Creates a Dictionary<TKey,TValue> from the query by enumerating it asynchronously according to a specified key selector function, a comparer, and an element selector function.

(Inherited from DbRawSqlQuery<TElement>)
ToDictionaryAsync<TKey>(Func<TElement,TKey>)

Creates a Dictionary<TKey,TValue> from the query by enumerating it asynchronously according to a specified key selector function.

(Inherited from DbRawSqlQuery<TElement>)
ToDictionaryAsync<TKey>(Func<TElement,TKey>, CancellationToken)

Creates a Dictionary<TKey,TValue> from the query by enumerating it asynchronously according to a specified key selector function.

(Inherited from DbRawSqlQuery<TElement>)
ToDictionaryAsync<TKey>(Func<TElement,TKey>, IEqualityComparer<TKey>)

Creates a Dictionary<TKey,TValue> from the query by enumerating it asynchronously according to a specified key selector function and a comparer.

(Inherited from DbRawSqlQuery<TElement>)
ToDictionaryAsync<TKey>(Func<TElement,TKey>, IEqualityComparer<TKey>, CancellationToken)

Creates a Dictionary<TKey,TValue> from the query by enumerating it asynchronously according to a specified key selector function and a comparer.

(Inherited from DbRawSqlQuery<TElement>)
ToListAsync()

Creates a List<T> from the query by enumerating it asynchronously.

(Inherited from DbRawSqlQuery<TElement>)
ToListAsync(CancellationToken)

Creates a List<T> from the query by enumerating it asynchronously.

(Inherited from DbRawSqlQuery<TElement>)
ToString()

Returns a String that contains the SQL string that was set when the query was created. The parameters are not included.

Explicit Interface Implementations

IDbAsyncEnumerable.GetAsyncEnumerator()

Returns an IDbAsyncEnumerable which when enumerated will execute the SQL query against the database.

(Inherited from DbRawSqlQuery<TElement>)
IDbAsyncEnumerable<TElement>.GetAsyncEnumerator()

Returns an IDbAsyncEnumerable<T> which when enumerated will execute the SQL query against the database.

(Inherited from DbRawSqlQuery<TElement>)
IEnumerable.GetEnumerator()

Executes the query and returns an enumerator for the elements.

IEnumerable.GetEnumerator()

Returns an IEnumerator which when enumerated will execute the SQL query against the database.

(Inherited from DbRawSqlQuery<TElement>)
IListSource.ContainsListCollection

Returns false.

IListSource.ContainsListCollection

Returns false.

(Inherited from DbRawSqlQuery<TElement>)
IListSource.GetList()

Throws an exception indicating that binding directly to a store query is not supported.

IListSource.GetList()

Throws an exception indicating that binding directly to a store query is not supported.

(Inherited from DbRawSqlQuery<TElement>)

Applies to