IdeaBlade.EntityModel.Compat Assembly > IdeaBlade.EntityModel.Compat Namespace > EntityManagerAsyncExtensions Class > ExecuteQueryAsync Method : ExecuteQueryAsync<T>(EntityManager,IEntityQuery<T>,Action<EntityQueryOperation<T>>,Object) Method |
'Declaration
<ExtensionAttribute()> Public Overloads Shared Function ExecuteQueryAsync(Of T)( _ ByVal em As EntityManager, _ ByVal query As IEntityQuery(Of T), _ ByVal userCallback As Action(Of EntityQueryOperation(Of T)), _ Optional ByVal userState As Object _ ) As EntityQueryOperation(Of T)
'Usage
Dim em As EntityManager Dim query As IEntityQuery(Of T) Dim userCallback As Action(Of EntityQueryOperation(Of T)) Dim userState As Object Dim value As EntityQueryOperation(Of T) value = EntityManagerAsyncExtensions.ExecuteQueryAsync(Of T)(em, query, userCallback, userState)
[Extension()] public static EntityQueryOperation<T> ExecuteQueryAsync<T>( EntityManager em, IEntityQuery<T> query, Action<EntityQueryOperation<T>> userCallback, object userState )
private void SampleAsynchQuery() { DomainModelEntityManager mgr = new DomainModelEntityManager(); // Build a query and ask mgr to run it asynchronously. var query = mgr.Customers.Where(c => c.CompanyName.StartsWith("C")); int token = 1; mgr.ExecuteQueryAsync(query, AsyncQueryCompleted, token); } void AsyncQueryCompleted(EntityQueryOperation<Customer> e) { if (e.Error != null) { System.Diagnostics.Debug.WriteLine(e.Error.Message); return; } System.Diagnostics.Debug.WriteLine("queryid = " + e.UserState.ToString()); System.Diagnostics.Debug.WriteLine("customers retrieved = " + e.Results.Count().ToString()); }
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