Created
August 21, 2009 03:07
-
-
Save Phanatic/171620 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Executes the URI and loads the DataServiceCollection with the results of the request | |
| /// </summary> | |
| /// <typeparam name="TEntity">The entity type for the DataServiceCollection</typeparam> | |
| /// <param name="context">The DataServiceContext instance that will be used | |
| to query the DataService</param> | |
| /// <param name="collection">The DataServiceCollection<paramref name="TEntity"/> | |
| which will be loaded the the results of this query</param> | |
| /// <param name="requestUri">The URI to query for data from the DataService</param> | |
| public static void LoadDataServiceCollection<TEntity>(this DataServiceContext context, | |
| DataServiceCollection<TEntity> collection, | |
| Uri requestUri) { | |
| context.BeginExecute<TEntity>(requestUri, | |
| (asResult) =>{ | |
| Application.Current.RootVisual.Dispatcher.BeginInvoke(() => { | |
| try { | |
| var dsCollection = asResult.AsyncState as DataServiceCollection<TEntity>; | |
| var queryResponse = context.EndExecute<TEntity>(asResult) | |
| as QueryOperationResponse<TEntity>; | |
| dsCollection.Add(resultEntity); | |
| } | |
| else { | |
| dsCollection.Load(queryResponse); | |
| } | |
| } | |
| catch (Exception) { | |
| throw; | |
| } | |
| finally { | |
| } | |
| } | |
| ); | |
| }, collection); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment