/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)" /> when this page was initially requested.</param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { var serviceRoot = new Uri(ServiceConstants.ServiceRootUrl); data = new s.martinbeEntities(serviceRoot); movies = new DataServiceCollection <s.Movie>(); actors = new DataServiceCollection <s.Actor>(); }
/// <summary> /// Sets up query and handles it. /// </summary> public void SetupQuery() { var serviceRoot = new Uri(ServiceConstants.ServiceRootUrl); data = new s.martinbeEntities(serviceRoot); var query = (DataServiceQuery <s.Movie>)data.Movie.Expand("Actor").OrderBy(c => c.Title); movies = new DataServiceCollection <s.Movie>(); //Use of delegate movies.LoadCompleted += movies_LoadCompleted; movies.LoadAsync(query); }
/// <summary> /// Updates this instance. /// </summary> public static void Update() { dataSource = new ActorMovieDataSource(); //Live tile lives in its own data world. To not interfere with GroupedItemsPage LoadAsync and add data twice. var serviceRoot = new Uri(ServiceConstants.ServiceRootUrl); data = new s.martinbeEntities(serviceRoot); //Example of lambda expression var query = (DataServiceQuery <s.Movie>)data.Movie.Expand("Actor").OrderBy(c => c.Title); movies = new DataServiceCollection <s.Movie>(); //Use of delegate movies.LoadCompleted += movies_LoadCompleted; movies.LoadAsync(query); }
//Example of lambda expression private async void actor_OnDatabaseSaved(IAsyncResult ar) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { data = ar.AsyncState as s.martinbeEntities; try { data.EndSaveChanges(ar); actors.LoadAsync((DataServiceQuery <s.Actor>)data.Actor.Expand("Actor").OrderBy(m => m.Title)); } catch (DataServiceRequestException ex) { Debug.WriteLine(ex.Message + " :: " + ex.InnerException.Message); } } ); }