Export (0) Print
Expand All

DbSqlQuery<TEntity> Class

[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]

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.Object
  System.Data.Entity.Infrastructure.DbRawSqlQuery<TEntity>
    System.Data.Entity.Infrastructure.DbSqlQuery<TEntity>

Namespace:  System.Data.Entity.Infrastructure
Assembly:  EntityFramework (in EntityFramework.dll)

[SuppressMessageAttribute("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public class DbSqlQuery<TEntity> : DbRawSqlQuery<TEntity>
where TEntity : class

Type Parameters

TEntity

The type of entities returned by the query.

The DbSqlQuery<TEntity> type exposes the following members.

  NameDescription
Protected methodDbSqlQuery<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.
Top

  NameDescription
Public methodAllAsync(Func<TElement, Boolean>)Asynchronously determines whether all the elements of the query satisfy a condition. (Inherited from DbRawSqlQuery<TElement>.)
Public methodAllAsync(Func<TElement, Boolean>, CancellationToken)Asynchronously determines whether all the elements of the query satisfy a condition. (Inherited from DbRawSqlQuery<TElement>.)
Public methodAnyAsync()Asynchronously determines whether the query contains any elements. (Inherited from DbRawSqlQuery<TElement>.)
Public methodAnyAsync(Func<TElement, Boolean>)Asynchronously determines whether any element of the query satisfies a condition. (Inherited from DbRawSqlQuery<TElement>.)
Public methodAnyAsync(CancellationToken)Asynchronously determines whether the query contains any elements. (Inherited from DbRawSqlQuery<TElement>.)
Public methodAnyAsync(Func<TElement, Boolean>, CancellationToken)Asynchronously determines whether any element of the query satisfies a condition. (Inherited from DbRawSqlQuery<TElement>.)
Public methodAsNoTrackingReturns a new query where the entities returned will not be cached in the DbContext.
Public methodAsStreaming Obsolete. Returns a new query that will stream the results instead of buffering.
Public methodContainsAsync(TElement)Asynchronously determines whether the query contains a specified element by using the default equality comparer. (Inherited from DbRawSqlQuery<TElement>.)
Public methodContainsAsync(TElement, CancellationToken)Asynchronously determines whether the query contains a specified element by using the default equality comparer. (Inherited from DbRawSqlQuery<TElement>.)
Public methodCountAsync()Asynchronously returns the number of elements in the query. (Inherited from DbRawSqlQuery<TElement>.)
Public methodCountAsync(Func<TElement, Boolean>)Asynchronously returns the number of elements in the query that satisfy a condition. (Inherited from DbRawSqlQuery<TElement>.)
Public methodCountAsync(CancellationToken)Asynchronously returns the number of elements in the query. (Inherited from DbRawSqlQuery<TElement>.)
Public methodCountAsync(Func<TElement, Boolean>, CancellationToken)Asynchronously returns the number of elements in the query that satisfy a condition. (Inherited from DbRawSqlQuery<TElement>.)
Public methodEqualsSpecifies whether this instance is equal to a specified object. (Overrides DbRawSqlQuery<TElement>.Equals(Object).)
Protected methodFinalize (Inherited from Object.)
Public methodFirstAsync()Asynchronously returns the first element of the query. (Inherited from DbRawSqlQuery<TElement>.)
Public methodFirstAsync(Func<TElement, Boolean>)Asynchronously returns the first element of the query that satisfies a specified condition. (Inherited from DbRawSqlQuery<TElement>.)
Public methodFirstAsync(CancellationToken)Asynchronously returns the first element of the query. (Inherited from DbRawSqlQuery<TElement>.)
Public methodFirstAsync(Func<TElement, Boolean>, CancellationToken)Asynchronously returns the first element of the query that satisfies a specified condition. (Inherited from DbRawSqlQuery<TElement>.)
Public methodFirstOrDefaultAsync()Asynchronously returns the first element of the query, or a default value if the the query result contains no elements. (Inherited from DbRawSqlQuery<TElement>.)
Public methodFirstOrDefaultAsync(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>.)
Public methodFirstOrDefaultAsync(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>.)
Public methodFirstOrDefaultAsync(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>.)
Public methodForEachAsync(Action<TElement>)Asynchronously enumerates the query results and performs the specified action on each element. (Inherited from DbRawSqlQuery<TElement>.)
Public methodForEachAsync(Action<TElement>, CancellationToken)Asynchronously enumerates the query results and performs the specified action on each element. (Inherited from DbRawSqlQuery<TElement>.)
Public methodGetEnumeratorReturns an IEnumerator<T> which when enumerated will execute the SQL query against the database. (Inherited from DbRawSqlQuery<TElement>.)
Public methodGetHashCodeGets the hash code associated with this instance. (Overrides DbRawSqlQuery<TElement>.GetHashCode().)
Public methodGetTypeGets the type associated with this instance.
Public methodLongCountAsync()Asynchronously returns an Int64 that represents the total number of elements in the query. (Inherited from DbRawSqlQuery<TElement>.)
Public methodLongCountAsync(Func<TElement, Boolean>)Asynchronously returns an Int64 that represents the number of elements in the query that satisfy a condition. (Inherited from DbRawSqlQuery<TElement>.)
Public methodLongCountAsync(CancellationToken)Asynchronously returns an Int64 that represents the total number of elements in the query. (Inherited from DbRawSqlQuery<TElement>.)
Public methodLongCountAsync(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>.)
Public methodMaxAsync()Asynchronously returns the maximum value of the query. (Inherited from DbRawSqlQuery<TElement>.)
Public methodMaxAsync(CancellationToken)Asynchronously returns the maximum value of the query. (Inherited from DbRawSqlQuery<TElement>.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodMinAsync()Asynchronously returns the minimum value of the query. (Inherited from DbRawSqlQuery<TElement>.)
Public methodMinAsync(CancellationToken)Asynchronously returns the minimum value of the query. (Inherited from DbRawSqlQuery<TElement>.)
Public methodSingleAsync()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>.)
Public methodSingleAsync(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>.)
Public methodSingleAsync(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>.)
Public methodSingleAsync(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>.)
Public methodSingleOrDefaultAsync()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>.)
Public methodSingleOrDefaultAsync(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>.)
Public methodSingleOrDefaultAsync(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>.)
Public methodSingleOrDefaultAsync(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>.)
Public methodToArrayAsync()Creates an array from the query by enumerating it asynchronously. (Inherited from DbRawSqlQuery<TElement>.)
Public methodToArrayAsync(CancellationToken)Creates an array from the query by enumerating it asynchronously. (Inherited from DbRawSqlQuery<TElement>.)
Public methodToDictionaryAsync<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>.)
Public methodToDictionaryAsync<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>.)
Public methodToDictionaryAsync<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>.)
Public methodToDictionaryAsync<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>.)
Public methodToDictionaryAsync<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>.)
Public methodToDictionaryAsync<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>.)
Public methodToDictionaryAsync<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>.)
Public methodToDictionaryAsync<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>.)
Public methodToListAsync()Creates a List<T> from the query by enumerating it asynchronously. (Inherited from DbRawSqlQuery<TElement>.)
Public methodToListAsync(CancellationToken)Creates a List<T> from the query by enumerating it asynchronously. (Inherited from DbRawSqlQuery<TElement>.)
Public methodToStringReturns a string representation of this instance. (Overrides DbRawSqlQuery<TElement>.ToString().)
Top

  NameDescription
Explicit interface implemetationPrivate propertyIListSource.ContainsListCollectionReturns false. (Inherited from DbRawSqlQuery<TElement>.)
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorReturns an IEnumerator which when enumerated will execute the SQL query against the database. (Inherited from DbRawSqlQuery<TElement>.)
Explicit interface implemetationPrivate methodIListSource.GetListThrows an exception indicating that binding directly to a store query is not supported. (Inherited from DbRawSqlQuery<TElement>.)
Explicit interface implemetationPrivate methodIDbAsyncEnumerable.GetAsyncEnumeratorReturns an IDbAsyncEnumerable which when enumerated will execute the SQL query against the database. (Inherited from DbRawSqlQuery<TElement>.)
Explicit interface implemetationPrivate methodIDbAsyncEnumerable<TElement>.GetAsyncEnumeratorReturns IDbAsyncEnumerator<T> which when enumerated will execute the SQL query against the database. (Inherited from DbRawSqlQuery<TElement>.)
Top

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft