ObjectContext.ExecuteStoreQueryAsync ObjectContext.ExecuteStoreQueryAsync ObjectContext.ExecuteStoreQueryAsync Method

Definition

Overloads

ExecuteStoreQueryAsync<TElement>(String, Object[]) ExecuteStoreQueryAsync<TElement>(String, Object[]) ExecuteStoreQueryAsync<TElement>(String, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. Results are not tracked by the context, use the overload that specifies an entity set name to track results.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreQueryAsync<TElement>(String, ExecutionOptions, Object[]) ExecuteStoreQueryAsync<TElement>(String, ExecutionOptions, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. Results are not tracked by the context, use the overload that specifies an entity set name to track results.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreQueryAsync<TElement>(String, CancellationToken, Object[]) ExecuteStoreQueryAsync<TElement>(String, CancellationToken, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. Results are not tracked by the context, use the overload that specifies an entity set name to track results.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreQueryAsync<TElement>(String, ExecutionOptions, CancellationToken, Object[]) ExecuteStoreQueryAsync<TElement>(String, ExecutionOptions, CancellationToken, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. Results are not tracked by the context, use the overload that specifies an entity set name to track results.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreQueryAsync<TElement>(String, String, ExecutionOptions, Object[]) ExecuteStoreQueryAsync<TElement>(String, String, ExecutionOptions, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. If an entity set name is specified, results are tracked by the context.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreQueryAsync<TElement>(String, String, ExecutionOptions, CancellationToken, Object[]) ExecuteStoreQueryAsync<TElement>(String, String, ExecutionOptions, CancellationToken, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. If an entity set name is specified, results are tracked by the context.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreQueryAsync<TElement>(String, Object[]) ExecuteStoreQueryAsync<TElement>(String, Object[]) ExecuteStoreQueryAsync<TElement>(String, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. Results are not tracked by the context, use the overload that specifies an entity set name to track results.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<TElement>> ExecuteStoreQueryAsync<TElement> (string commandText, params object[] parameters);
member this.ExecuteStoreQueryAsync : string * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>
Public Function ExecuteStoreQueryAsync(Of TElement) (commandText As String, ParamArray parameters As Object()) As Task(Of ObjectResult(Of TElement))

Type Parameters

TElement

The element type of the result sequence.

Parameters

commandText
String String String

The query specified in the server's native query language.

parameters
Object[]

The parameter values to use for the query. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Returns

Task<ObjectResult<TElement>>

A task that represents the asynchronous operation. The task result contains an enumeration of objects of type TElement .

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

ExecuteStoreQueryAsync<TElement>(String, ExecutionOptions, Object[]) ExecuteStoreQueryAsync<TElement>(String, ExecutionOptions, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. Results are not tracked by the context, use the overload that specifies an entity set name to track results.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public virtual System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<TElement>> ExecuteStoreQueryAsync<TElement> (string commandText, System.Data.Entity.Core.Objects.ExecutionOptions executionOptions, params object[] parameters);
abstract member ExecuteStoreQueryAsync : string * System.Data.Entity.Core.Objects.ExecutionOptions * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>
override this.ExecuteStoreQueryAsync : string * System.Data.Entity.Core.Objects.ExecutionOptions * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>

Type Parameters

TElement

The element type of the result sequence.

Parameters

commandText
String String String

The query specified in the server's native query language.

executionOptions
ExecutionOptions ExecutionOptions ExecutionOptions

The options for executing this query.

parameters
Object[]

The parameter values to use for the query. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Returns

Task<ObjectResult<TElement>>

A task that represents the asynchronous operation. The task result contains an enumeration of objects of type TElement .

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

ExecuteStoreQueryAsync<TElement>(String, CancellationToken, Object[]) ExecuteStoreQueryAsync<TElement>(String, CancellationToken, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. Results are not tracked by the context, use the overload that specifies an entity set name to track results.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public virtual System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<TElement>> ExecuteStoreQueryAsync<TElement> (string commandText, System.Threading.CancellationToken cancellationToken, params object[] parameters);
abstract member ExecuteStoreQueryAsync : string * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>
override this.ExecuteStoreQueryAsync : string * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>

Type Parameters

TElement

The element type of the result sequence.

Parameters

commandText
String String String

The query specified in the server's native query language.

cancellationToken
CancellationToken CancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

parameters
Object[]

The parameter values to use for the query. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Returns

Task<ObjectResult<TElement>>

A task that represents the asynchronous operation. The task result contains an enumeration of objects of type TElement .

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

ExecuteStoreQueryAsync<TElement>(String, ExecutionOptions, CancellationToken, Object[]) ExecuteStoreQueryAsync<TElement>(String, ExecutionOptions, CancellationToken, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. Results are not tracked by the context, use the overload that specifies an entity set name to track results.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public virtual System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<TElement>> ExecuteStoreQueryAsync<TElement> (string commandText, System.Data.Entity.Core.Objects.ExecutionOptions executionOptions, System.Threading.CancellationToken cancellationToken, params object[] parameters);
abstract member ExecuteStoreQueryAsync : string * System.Data.Entity.Core.Objects.ExecutionOptions * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>
override this.ExecuteStoreQueryAsync : string * System.Data.Entity.Core.Objects.ExecutionOptions * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>

Type Parameters

TElement

The element type of the result sequence.

Parameters

commandText
String String String

The query specified in the server's native query language.

executionOptions
ExecutionOptions ExecutionOptions ExecutionOptions

The options for executing this query.

cancellationToken
CancellationToken CancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

parameters
Object[]

The parameter values to use for the query. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Returns

Task<ObjectResult<TElement>>

A task that represents the asynchronous operation. The task result contains an enumeration of objects of type TElement .

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

ExecuteStoreQueryAsync<TElement>(String, String, ExecutionOptions, Object[]) ExecuteStoreQueryAsync<TElement>(String, String, ExecutionOptions, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. If an entity set name is specified, results are tracked by the context.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<TElement>> ExecuteStoreQueryAsync<TElement> (string commandText, string entitySetName, System.Data.Entity.Core.Objects.ExecutionOptions executionOptions, params object[] parameters);
member this.ExecuteStoreQueryAsync : string * string * System.Data.Entity.Core.Objects.ExecutionOptions * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>

Type Parameters

TElement

The element type of the result sequence.

Parameters

commandText
String String String

The query specified in the server's native query language.

entitySetName
String String String

The entity set of the TResult type. If an entity set name is not provided, the results are not going to be tracked.

executionOptions
ExecutionOptions ExecutionOptions ExecutionOptions

The options for executing this query.

parameters
Object[]

The parameter values to use for the query. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Returns

Task<ObjectResult<TElement>>

A task that represents the asynchronous operation. The task result contains an enumeration of objects of type TElement .

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

ExecuteStoreQueryAsync<TElement>(String, String, ExecutionOptions, CancellationToken, Object[]) ExecuteStoreQueryAsync<TElement>(String, String, ExecutionOptions, CancellationToken, Object[])

Asynchronously executes a query directly against the data source and returns a sequence of typed results. The query is specified using the server's native query language, such as SQL. If an entity set name is specified, results are tracked by the context.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreQueryAsync<Post>("SELECT * FROM dbo.Posts WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public virtual System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<TElement>> ExecuteStoreQueryAsync<TElement> (string commandText, string entitySetName, System.Data.Entity.Core.Objects.ExecutionOptions executionOptions, System.Threading.CancellationToken cancellationToken, params object[] parameters);
abstract member ExecuteStoreQueryAsync : string * string * System.Data.Entity.Core.Objects.ExecutionOptions * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>
override this.ExecuteStoreQueryAsync : string * string * System.Data.Entity.Core.Objects.ExecutionOptions * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<System.Data.Entity.Core.Objects.ObjectResult<'Element>>

Type Parameters

TElement

The element type of the result sequence.

Parameters

commandText
String String String

The query specified in the server's native query language.

entitySetName
String String String

The entity set of the TResult type. If an entity set name is not provided, the results are not going to be tracked.

executionOptions
ExecutionOptions ExecutionOptions ExecutionOptions

The options for executing this query.

cancellationToken
CancellationToken CancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

parameters
Object[]

The parameter values to use for the query. If output parameters are used, their values will not be available until the results have been read completely. This is due to the underlying behavior of DbDataReader, see http://go.microsoft.com/fwlink/?LinkID=398589 for more details.

Returns

Task<ObjectResult<TElement>>

A task that represents the asynchronous operation. The task result contains an enumeration of objects of type TElement .

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

Applies to