DevForce Help Reference
SingleOrNullEntity<TSource>(IEntityScalarQuery<TSource>) Method
Example 


Returns the only element of a sequence, or the appropriate NullEntity if the sequence is empty; this method throws an exception if there is more than one element in the sequence.
Syntax
'Declaration
 
<ExtensionAttribute()>
Public Overloads Shared Function SingleOrNullEntity(Of TSource)( _
   ByVal source As IEntityScalarQuery(Of TSource) _
) As Task(Of TSource)
'Usage
 
Dim source As IEntityScalarQuery(Of TSource)
Dim value As Task(Of TSource)
 
value = EntityScalarAsyncExtensions.SingleOrNullEntity(Of TSource)(source)
[Extension()]
public static Task<TSource> SingleOrNullEntity<TSource>( 
   IEntityScalarQuery<TSource> source
)

Parameters

source

Type Parameters

TSource
Example
public async void AsyncSingleOrNullEntity() {
  Employee emp = await _entityManager.Employees.Where(e => e.Id == 1).AsScalarAsync().SingleOrNullEntity();
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EntityScalarAsyncExtensions Class
EntityScalarAsyncExtensions Members
Overload List

Send Feedback