DbRawSqlQuery<TElement>::FirstOrDefaultAsync Method

Entity Framework 6.0
 

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

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

NameDescription
System_CAPS_pubmethodFirstOrDefaultAsync()

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

System_CAPS_pubmethodFirstOrDefaultAsync(CancellationToken)

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

System_CAPS_pubmethodFirstOrDefaultAsync(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.

System_CAPS_pubmethodFirstOrDefaultAsync(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.

Return to top

DbRawSqlQuery<TElement>::FirstOrDefaultAsync Method ()

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

public:
Task<TElement>^ FirstOrDefaultAsync()

Return Value

Type: System.Threading.Tasks::Task<TElement>^

A task that represents the asynchronous operation. The task result contains default ( TElement ) if query result is empty; otherwise, the first element in the query result.

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.

Return to top

DbRawSqlQuery<TElement>::FirstOrDefaultAsync Method (CancellationToken)

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

public:
Task<TElement>^ FirstOrDefaultAsync(
	CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading::CancellationToken

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

Return Value

Type: System.Threading.Tasks::Task<TElement>^

A task that represents the asynchronous operation. The task result contains default ( TElement ) if query result is empty; otherwise, the first element in the query result.

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.

Return to top

DbRawSqlQuery<TElement>::FirstOrDefaultAsync Method (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.

public:
Task<TElement>^ FirstOrDefaultAsync(
	Func<TElement, bool>^ predicate
)

Parameters

predicate
Type: System::Func<TElement, Boolean>^

A function to test each element for a condition.

Return Value

Type: System.Threading.Tasks::Task<TElement>^

A task that represents the asynchronous operation. The task result contains default ( TElement ) if query result is empty or if no element passes the test specified by predicate ; otherwise, the first element in the query result that passes the test specified by predicate .

Exception Condition
ArgumentNullException

predicate is null .

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.

Return to top

DbRawSqlQuery<TElement>::FirstOrDefaultAsync Method (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.

public:
Task<TElement>^ FirstOrDefaultAsync(
	Func<TElement, bool>^ predicate,
	CancellationToken cancellationToken
)

Parameters

predicate
Type: System::Func<TElement, Boolean>^

A function to test each element for a condition.

cancellationToken
Type: System.Threading::CancellationToken

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

Return Value

Type: System.Threading.Tasks::Task<TElement>^

A task that represents the asynchronous operation. The task result contains default ( TElement ) if query result is empty or if no element passes the test specified by predicate ; otherwise, the first element in the query result that passes the test specified by predicate .

Exception Condition
ArgumentNullException

predicate is null .

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.

Return to top
Show: