public static Task <DataServiceCollection <T> > AsyncQuery <T>( this DataServiceCollection <T> data, IQueryable <T> query = null) { var asyncr = new SimpleAsyncResult(); Exception exResult = null; data.LoadCompleted += delegate(object sender, LoadCompletedEventArgs e) { exResult = e.Error; asyncr.Finish(); }; if (query == null) { data.LoadAsync(); } else { data.LoadAsync(query); } return(Task <DataServiceCollection <T> > .Factory.FromAsync(asyncr , r => { if (exResult != null) { throw new AggregateException("Async call problem", exResult); } return data; } )); }
public void LoadSponsors() { Sponsors = new DataServiceCollection <Sponsor>(context); var query = from s in context.Sponsors.OrderBy(s => s.Name) select s; Sponsors.LoadAsync(query); }
/// <summary> /// Reloads notes from server /// </summary> private void LoadData() { this.IsDataLoaded = false; this.IsUiEnabled = false; // preparing a data context this._context = new NotesDataContext(new Uri(ServiceUri + "/Services/NotesDataService.svc")); Debug.Assert(!string.IsNullOrEmpty(this.AuthSchema), "The AuthSchema property should be initialized!"); // passing the authentication token obtained from Microsoft Account via the Authorization header this._context.SendingRequest += (sender, args) => { // let our header look a bit custom args.RequestHeaders["Authorization"] = this.AuthSchema + " " + this._authenticationToken; }; var notes = new DataServiceCollection <Note>(this._context); notes.LoadCompleted += (sender, args) => { if (this.Notes.Continuation != null) { this.Notes.LoadNextPartialSetAsync(); return; } if (args.Error == null) { this.IsDataLoaded = true; } else { this.OnError.FireSafely(args.Error); } this.IsUiEnabled = true; }; // Defining a query var query = from note in this._context.Notes orderby note.TimeCreated descending select note; // Demonstrating LINQ query dynamic generation. notes.LoadAsync ( this._showTodaysNotesOnly ? // This will be translated into DynamoDb Query on the server, like this: // DynamoDb index query: SELECT * FROM Note WHERE TimeCreated GreaterThan <some DateTime> AND UserId Equal <some userId> ORDER BY TimeCreated DESC. Index name: TimeCreatedIndex query.Where(note => note.TimeCreated > DateTime.Today) : query ); this.Notes = notes; this.NotifyPropertyChanged(() => this.Notes); }
public void LoadAsyncTest() { var context = this.CreateWrappedContext <DefaultContainer>().Context; var query = context.Customer; var dataServiceCollection = new DataServiceCollection <Customer>(); dataServiceCollection.LoadCompleted += (sender, e) => { if (e.Error == null) { if (dataServiceCollection.Continuation != null) { dataServiceCollection.LoadNextPartialSetAsync(); } else { this.EnqueueTestComplete(); Assert.Equal(10, dataServiceCollection.Count); } } }; dataServiceCollection.LoadAsync(query); this.WaitForTestToComplete(); }
public void LoadSpeakers() { Speakers = new DataServiceCollection <Person>(context); var query = context.CreateQuery <Person>("Speakers").AddQueryOption("eventId", Constants.EventId).OrderBy(p => p.LastName); Speakers.LoadAsync(query); }
public static Task LoadQueryAsync <T>(this DataServiceCollection <T> collection, IQueryable <T> query) { TaskCompletionSource <object> taskCompletationSource = new TaskCompletionSource <object>(); EventHandler <LoadCompletedEventArgs> onCompleted = null; onCompleted = (e, sender) => { collection.LoadCompleted -= onCompleted; if (sender.Cancelled) { taskCompletationSource.SetCanceled(); } else if (sender.Error != null) { taskCompletationSource.SetException(sender.Error); } else { taskCompletationSource.SetResult(null); } }; collection.LoadCompleted += onCompleted; collection.LoadAsync(query); return(taskCompletationSource.Task); }
// Load data for the ViewModel Items protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); try { if (_taskResult != null) { var bg = new DataServiceCollection <AutoMgrSvc.barcode_goods>(); bg.LoadCompleted += new EventHandler <LoadCompletedEventArgs>((sender, e1) => { if (e1.Error == null) { if (bg.Count > 0) { goods.Text = bg[0].goods.name; } } }); var query = from bgs in ctx.barcode_goods.Expand("goods") where bgs.barcode == _taskResult.Text select bgs; bg.LoadAsync(query); } } catch (Exception ex) { } }
public void LoadTracks() { Tracks = new DataServiceCollection <Track>(context); var query = from t in context.Tracks.Where(t => t.Event_ID == Constants.EventId) select t; Tracks.LoadAsync(query); }
public void LoadAnnouncements() { Announcements = new DataServiceCollection <Announcement>(context); var query = from a in context.Announcements.OrderByDescending(a => a.PublishDate) select a; Announcements.LoadAsync(query); }
public void LoadSessions() { Sessions = new DataServiceCollection <Session>(context); var query = from s in context.Sessions where s.Event_ID == Constants.EventId select s; Sessions.LoadAsync(query); }
private void CodeFirst_Page_Loaded(object sender, RoutedEventArgs e) { // Initialize the context and the binding collection context = new ProductContext(northwindUri); products = new DataServiceCollection<Product>(context); context.Products.AddQueryOption("$top", 10); // Define a LINQ query that returns all customers. var query = from cust in context.Products //where cust.ProductId == 2761685473 select cust; var query2 = context.Products.Take(10); // Register for the LoadCompleted event. products.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(products_LoadCompleted); // Load the customers feed by executing the LINQ query. products.LoadAsync(query); }
/// <summary> /// Asynchronously executes an <see cref="T:System.Linq.IQueryable`1"/> and loads results into the <see cref="T:System.Data.Services.Client.DataServiceCollection`1"/>. /// </summary> /// <typeparam name="T">Entity type of the <see cref="T:System.Data.Services.Client.DataServiceCollection`1"/> instance.</typeparam> /// <param name="bindingCollection">The <see cref="T:System.Data.Services.Client.DataServiceCollection`1"/> instance on which this extension method is enabled.</param> /// <param name="query">Query that when executed loads entities into the collection.</param> /// <returns>A <see cref="T:System.Threading.Tasks.Task`1"/> that, when completed, returns a <see cref="T:System.Data.Services.Client.LoadCompletedEventArgs"/>.</returns> public static async Task <LoadCompletedEventArgs> LoadAsync <T>(this DataServiceCollection <T> bindingCollection, IQueryable <T> query) { var tcs = new TaskCompletionSource <LoadCompletedEventArgs>(); EventHandler <LoadCompletedEventArgs> handler = delegate(object o, LoadCompletedEventArgs e) { if (e.Error != null) { tcs.TrySetException(e.Error); } else if (e.Cancelled) { tcs.TrySetCanceled(); } else { tcs.TrySetResult(e); } }; bindingCollection.LoadCompleted += handler; bindingCollection.LoadAsync(query); LoadCompletedEventArgs eventArgs = await tcs.Task; bindingCollection.LoadCompleted -= handler; return(eventArgs); }
private void MellowSongsLoadButton_Click(object sender, RoutedEventArgs e) { var query = from s in musicEntities.MellowSongs select s; MellowSongs.LoadCompleted += MellowSongs_LoadCompleted; MellowSongs.LoadAsync(query); }
public void LoadTimeslots() { Timeslots = new DataServiceCollection <Timeslot>(context); var query = from ts in context.Timeslots select ts; Timeslots.LoadAsync(query); }
private void UploadedSongsLoadButton_Click(object sender, RoutedEventArgs e) { var query = from s in musicEntities.SONG where s.UPLOADED == true orderby s.ID descending select s; Songs.LoadCompleted += Songs_LoadCompleted; Songs.LoadAsync(query); }
private void LoadResponsibleSubjects() { ResponsibleSubjects = new DataServiceCollection <ResponsibleSubject>(m_Context); var query = m_Context.ResponsibleSubjects.Expand("OpenResKit.DomainModel.Employee/Groups"); ResponsibleSubjects.LoadCompleted += (s, e) => LoadCarbonFootprints(); ResponsibleSubjects.LoadAsync(query); }
private void LoadAvailableProjects() { var uri = new Uri(_settings.ServiceUrl+"/Projects"); var context = IoC.Get<TFSDataServiceContext>(); _collection = new DataServiceCollection<Project>(context); _collection.LoadCompleted += this.ItemsLoadCompleted; _collection.LoadAsync(uri); }
public void LoadData() { var uri = new Uri(App.AWSERVICE); entities = new AdventureWorksLT2008R2Entities(uri); DSProducts = new DataServiceCollection<Product>(entities); var query = entities.Products; DSProducts.LoadAsync(query); }
private void RandomSongsLoadButton_Click(object sender, RoutedEventArgs e) { var query = from s in musicEntities.RandomSongs select s; RandomSongs.LoadCompleted += RandomSongs_LoadCompleted; RandomSongs.LoadAsync(query); SongGrid.ItemsSource = RandomSongs; }
/// <summary> /// Invoked when a filter is selected using the ComboBox in snapped view state. /// </summary> /// <param name="sender">The ComboBox instance.</param> /// <param name="e">Event data describing how the selected filter was changed.</param> void Filter_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Determine what filter was selected var selectedFilter = e.AddedItems.FirstOrDefault() as Filter; if (selectedFilter != null) { // Mirror the results into the corresponding Filter object to allow the // RadioButton representation used when not snapped to reflect the change selectedFilter.Active = true; // TODO: Respond to the change in active filter by setting this.DefaultViewModel["Results"] // to a collection of items with bindable Image, Title, Subtitle, and Description properties DefaultViewModel["Results"] = null; // clear previous result DefaultViewModel["Results"] = new ObservableCollection <SearchResult>(); var searchText = DefaultViewModel["QueryText"] as string; if (!String.IsNullOrEmpty(searchText)) { NetflixCatalog catalog = new NetflixCatalog(netflixServiceUri); var query = catalog.Titles.Where(t => t.Name.Contains(searchText)).Select(t => t); var queryResults = new DataServiceCollection <Title>(); queryResults.LoadCompleted += (o, args) => { if (queryResults.Continuation != null) { queryResults.LoadNextPartialSetAsync(); } else { DefaultViewModel["Results"] = queryResults.Select(t => new { Title = t.Name, Subtitle = t.ShortName, Description = t.ShortSynopsis, Image = t.BoxArt.MediumUrl }).ToList(); // ensure that results are found object results; ICollection resultsCollection; if (this.DefaultViewModel.TryGetValue("Results", out results) && (resultsCollection = results as ICollection) != null && resultsCollection.Count != 0) { VisualStateManager.GoToState(this, "ResultsFound", true); } } }; queryResults.LoadAsync(query); } } // Display informational text when there are no search results. VisualStateManager.GoToState(this, "NoResultsFound", true); }
// Loads data from the data service for the first time. public void LoadData() { // Instantiate the context and binding collection. _context = new PhotoDataContainer(svcRootUri); Photos = new DataServiceCollection <PhotoInfo>(_context); // Load the data from the PhotoInfo feed. Photos.LoadAsync(new Uri("/PhotoInfo", UriKind.Relative)); }
public SampleDataSource() { var data = new DataServiceCollection <JayStorm.Repository.Category>(SampleDataSource._context); data.LoadCompleted += data_LoadCompleted; var query = SampleDataSource._context.Categories; data.LoadAsync(query); }
private void LoadCarbonFootprints() { CarbonFootprints = new DataServiceCollection <CarbonFootprint>(m_Context); var query = m_Context.CarbonFootprints.Expand("Positions") .Expand("Positions/OpenResKit.DomainModel.CarbonFootprintPosition/ResponsibleSubject") .Expand("Positions/OpenResKit.DomainModel.AirportBasedFlight/Airports"); CarbonFootprints.LoadCompleted += (s, e) => RaiseEvent(ContextChanged); CarbonFootprints.LoadAsync(query); }
// Loads data for a specific page of Titles. public void LoadData(int page) { _currentPage = page; // Reset the binding collection. Titles = new DataServiceCollection <Title>(_context); // Load the data. Titles.LoadAsync(GetQuery()); }
public void DownloadNetflixTopTitles() { Deployment.Current.Dispatcher.BeginInvoke(() => { ShowProgressBar = true; }); topMovieTitles = new DataServiceCollection <Title>(ODataContext); topMovieTitles.LoadCompleted += new EventHandler <LoadCompletedEventArgs>(topMovieTitles_LoadCompleted); topMovieTitles.LoadAsync(new Uri("/Titles()", UriKind.Relative)); }
// Loads data when the application is initialized. public void LoadData() { // Instantiate the context and binding collection. _context = new NetflixCatalog(_rootUri); // Use the public property setter to generate a notification to the binding. Titles = new DataServiceCollection <Title>(_context); // Load the data. Titles.LoadAsync(GetQuery()); }
// Loads data when the application is initialized. public void LoadData() { // Instantiate the context and binding collection. _context = new NorthwindEntities(_rootUri); Customers = new DataServiceCollection <Customer>(_context); // Specify an OData query that returns all customers. var query = from cust in _context.Customers select cust; // Load the customer data. Customers.LoadAsync(query); }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { AdventureWorksEntities context = new AdventureWorksEntities( new Uri("http://localhost:9090/services/AdventureWorksRestOData.svc")); DataServiceCollection <Vendor> vendors = new DataServiceCollection <Vendor>(context); //Add REST URL for collection VendorsListBox.ItemsSource = vendors; vendors.LoadAsync(new Uri("/Vendors", UriKind.Relative)); }
public MainPage() { InitializeComponent(); Uri uri = new Uri("/BlogService.svc", UriKind.Relative); svc = new BlogContext(uri); blogs = new DataServiceCollection<Blogs>(svc); this.LayoutRoot.DataContext = blogs; blogs.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(blogs_LoadCompleted); var q = svc.Blogs; blogs.LoadAsync(q); }
/// <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> /// Downloads a radio map for the building with the specified id. /// </summary> /// <param name="buildingId"></param> public static void DownloadRadioMap(int buildingId) { radiomapContext = new radiomapEntities(radiomapUri); buildings = new DataServiceCollection <Building>(radiomapContext); String expandOptions = "Building_Floors,Vertices,Vertices/AbsoluteLocations,Vertices/SymbolicLocations,Vertices/Edges,Edges,Edges/Vertices,Edges/Vertices/AbsoluteLocations"; var query = from b in radiomapContext.Buildings.Expand(expandOptions) where b.ID == buildingId select b; // Register for the LoadCompleted event. buildings.LoadCompleted += new EventHandler <LoadCompletedEventArgs>(buildings_LoadCompleted); buildings.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); }
public ConsultationRDV() { InitializeComponent(); _context = new FUCHSEntities(new Uri("http://localhost:28898/WcfDataServiceTASSET.svc/", UriKind.Absolute)); ////////////////lesRdv//////////////////// vuerdv = new DataServiceCollection <VueRDV>(_context); vuerdv.LoadCompleted += new EventHandler <LoadCompletedEventArgs>(HandlevueRdvLoaded); DataServiceQuery <VueRDV> vuerdvquery = (DataServiceQuery <VueRDV>) from r in _context.VueRDV select r; vuerdv.LoadAsync(vuerdvquery); }
public void LoadData(bool upcomingOnly) { this.Message = string.Empty; _events = new DataServiceCollection <Event>(_context); // Register a handler for the LoadCompleted callback. _events.LoadCompleted += OnEventsLoaded; // Define a query for all events. var query = _context.Events.OrderBy(e => e.EventStartDate); // Load the data. _events.LoadAsync(query); // We have started loading data asynchronously. IsDataLoading = true; }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { DataServiceCollection<SampleData> sampleDataCollection; var context = CloudStorageContext.Current.Resolver.CreateTableServiceContext(); sampleDataCollection = new DataServiceCollection<SampleData>(context); sampleDataCollection.LoadCompleted += (s2, e2) => { List<SampleData> cloudNotes = sampleDataCollection.ToList(); ListPics.ItemsSource = cloudNotes; }; var tableUri = new Uri( string.Format( CultureInfo.InvariantCulture, "{0}/{1}()", context.BaseUri, "pics"), UriKind.Absolute); sampleDataCollection.Clear(); sampleDataCollection.LoadAsync(tableUri); }
public void LoadData() { SelectedPerson = null; People = new DataServiceCollection<Person>(context); People.LoadAsync(context.People); }
public void LoadAsyncTest() { var context = this.CreateWrappedContext<DefaultContainer>().Context; var query = context.Customer; var dataServiceCollection = new DataServiceCollection<Customer>(); dataServiceCollection.LoadCompleted += (sender, e) => { if (e.Error == null) { if (dataServiceCollection.Continuation != null) { dataServiceCollection.LoadNextPartialSetAsync(); } else { this.EnqueueTestComplete(); Assert.AreEqual(10, dataServiceCollection.Count); } } }; dataServiceCollection.LoadAsync(query); this.WaitForTestToComplete(); }
public SampleDataSource() { var data = new DataServiceCollection<JayStorm.Repository.Category>(SampleDataSource._context); data.LoadCompleted += data_LoadCompleted; var query = SampleDataSource._context.Categories; data.LoadAsync(query); }
static void data_LoadCompleted(object sender, LoadCompletedEventArgs e) { var result = sender as DataServiceCollection<JayStorm.Repository.Category>; foreach (var cat in result) { var group = new SampleDataGroup(cat.id, cat.CategoryName, cat.Name, cat.ImageUrl, cat.Description); var flowers = new DataServiceCollection<JayStorm.Repository.Flower>(SampleDataSource._context); flowers.LoadCompleted += flowers_LoadCompleted; flowers.LoadAsync(SampleDataSource._context.Flowers.Where(f => f.Category_ID == cat.id)); _sampleDataSource.AllGroups.Add(group); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); id = long.Parse(NavigationContext.QueryString["debtCalculationId"]); _container = ApiHelper.GetContainer(); _calculations = new DataServiceCollection<DebtCalculation>(_container); // Cannot localize ApplicationBar unless it is created in code behind ApplicationBar = new ApplicationBar { BackgroundColor = Color.FromArgb(255, 0x86, 0xC4, 0x40), //"#86C440" Opacity = 1, ForegroundColor = Colors.White }; ContentPanel.Children.Add(new ProgressBar { IsIndeterminate = true, Width = 300, Margin = new Thickness(0, 30, 0, 0) }); var query = _container.DebtCalculations .Expand("Expenses/Payer") .Expand("Expenses/Debtors/User") .Expand("Participants/User") .Expand("Debts/Debtor") .Expand("Debts/Creditor") .Expand(dc => dc.Creator) .Where(dc => dc.Id == id); _calculations.LoadCompleted += ShowCalculation; _calculations.LoadAsync(query); }
private void btnFindCommodity_Click(object sender, RoutedEventArgs e) { // Initialize the context and the binding collection context = new TopCarrotEntities(topCarrotDataUri); context.SendingRequest += new EventHandler<SendingRequestEventArgs>(context_SendingRequest); commodityPluCodes = new DataServiceCollection<CommodityPluCode>(context); //Show the progress bar pageIndicators.ShowProgress(this); if (UserInputUtilities.IsPluCode(txtCommodityToFind.Text)) { txtblkInstructions.Text = "By PLU code entered"; SearchQuery = from CommodityPluCode PluData in context.CommodityPluCodes where PluData.PLU == txtCommodityToFind.Text.ToString() select PluData; } if (UserInputUtilities.IsCropNumber(txtCommodityToFind.Text)) { txtblkInstructions.Text = "By crop ID entered"; SearchQuery = from CommodityPluCode PluData in context.CommodityPluCodes where PluData.Commodity == txtCommodityToFind.Text.ToUpper() select PluData; } else { txtblkInstructions.Text = "By commondity name entered"; SearchQuery = from CommodityPluCode PluData in context.CommodityPluCodes where PluData.Commodity == txtCommodityToFind.Text.ToUpper() select PluData; } // Register for the LoadCompleted event. commodityPluCodes.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(commodityPluCodes_LoadCompleted); // Load the customers feed by executing the LINQ query. commodityPluCodes.LoadAsync(SearchQuery); }
private void button_down_Click(object sender, RoutedEventArgs e) { //Uri uri = new Uri("/BlogService.svc", UriKind.Relative); Uri uri = new Uri("http://localhost:9430/BlogService.svc/"); svc = new BlogContext(uri); blogs = new DataServiceCollection<Blogs>(svc); blogs.LoadCompleted += new EventHandler<LoadCompletedEventArgs>((_sender,_e)=>{ LoadData(blogs); MessageBox.Show("Load completed"); }); var q = svc.Blogs; blogs.LoadAsync(q); }
/// <summary> /// Gets the details of the PLU or commodity that was selected on the Search By page /// </summary> /// <param name="PluId">The PLUID from the SQL table which is the same as the table ID</param> private void GetDetailInformation(int PluId) { // Initialize the context and the binding collection context = new TopCarrotEntities(topCarrotDataUri); commodityPluCodes = new DataServiceCollection<CommodityPluCode>(context); // Define a LINQ query that returns all customers. var query = from CommodityPluCode PluData in context.CommodityPluCodes where PluData.PLUId == PluId select PluData; // Register for the LoadCompleted event. commodityPluCodes.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(commodityPluCodes_LoadCompleted); // Load the customers feed by executing the LINQ query. commodityPluCodes.LoadAsync(query); }
public void GetSessions(Action<DataServiceCollection<Session>> onSuccess, Action<bool> onBusyStateChanged, Action<Exception> onError) { var sessions = new DataServiceCollection<Session>(null, TrackingMode.None); sessions.LoadCompleted += (s, e) => { DispatchBusyStateChanged(onBusyStateChanged, false); if (e.Cancelled) return; if (e.Error != null) DispatchError(e.Error, onError); else onSuccess(sessions); }; DispatchBusyStateChanged(onBusyStateChanged, true); sessions.LoadAsync(Context.Sessions); }
/// <summary> /// Reloads notes from server /// </summary> private void LoadData() { this.IsDataLoaded = false; this.IsUiEnabled = false; // preparing a data context this._context = new NotesDataContext(new Uri(NotesDataServiceUri)); // passing the authentication token obtained from Microsoft Account via the Authorization header this._context.SendingRequest += (sender, args) => { // let our header look a bit custom args.RequestHeaders["Authorization"] = Constants.AuthorizationHeaderPrefix + this._authenticationToken; }; var notes = new DataServiceCollection<Note>(this._context); notes.LoadCompleted += (sender, args) => { if (this.Notes.Continuation != null) { this.Notes.LoadNextPartialSetAsync(); return; } if (args.Error == null) { this.IsDataLoaded = true; } else { this.OnError.FireSafely(args.Error); } this.IsUiEnabled = true; }; // Defining a query var query = from note in this._context.Notes orderby note.TimeCreated descending select note; // Demonstrating LINQ query dynamic generation. notes.LoadAsync ( this._showTodaysNotesOnly ? // This will be translated into DynamoDb Query on the server, like this: // DynamoDb index query: SELECT * FROM Note WHERE TimeCreated GreaterThan <some DateTime> AND UserId Equal <some userId> ORDER BY TimeCreated DESC. Index name: TimeCreatedIndex query.Where(note => note.TimeCreated > DateTime.Today) : query ); this.Notes = notes; this.NotifyPropertyChanged(() => this.Notes); }
private void fetchData(string filter, Action<List<Post>> callback) { StackOverflow.StackOverflow context = new StackOverflow.StackOverflow(new System.Uri("https://odata.sqlazurelabs.com/OData.svc/v0.1/rp1uiewita/StackOverflow")); var query = from t in context.Posts where t.Tags.Contains("Silverlight") && t.Score > 5 select t; if (!String.IsNullOrWhiteSpace(filter)) query = query.Where(t => t.Body.Contains(filter) || t.Title.Contains(filter)); DataServiceCollection<Post> posts = new DataServiceCollection<Post>(); posts.LoadCompleted += (s, e) => { if (e.Error != null) throw e.Error; callback(posts.ToList()); }; posts.LoadAsync(query.OrderByDescending(t => t.CreationDate).Take(30)); }
// All to-do items. public void GetAllToDoItems() { var context = CloudStorageContext.Current.Resolver.CreateTableServiceContext(); DataServiceCollection<ToDoEntity> toDoEntityCollection = new DataServiceCollection<ToDoEntity>(context); toDoEntityCollection.LoadCompleted += (s, e) => { ApplicationStateHelpers.Set("loading", true); AllToDoItems = toDoEntityCollection; // Query the database and load all associated items to their respective collections. foreach (var category in CategoriesList) { switch (category) { case "Home": HomeToDoItems = Convert(AllToDoItems.Where(w => w.Category == category)); break; case "Work": WorkToDoItems = Convert(AllToDoItems.Where(w => w.Category == category)); break; case "Hobbies": HobbiesToDoItems = Convert(AllToDoItems.Where(w => w.Category == category)); break; default: break; } } ApplicationStateHelpers.Set("loading", false); }; var tableUri = new Uri( string.Format( CultureInfo.InvariantCulture, "{0}/{1}()", context.BaseUri, tableName, DateTime.UtcNow.Ticks), UriKind.Absolute); toDoEntityCollection.Clear(); toDoEntityCollection.LoadAsync(tableUri); }
/// <summary> /// Downloads a radio map for the building with the specified id. /// </summary> /// <param name="buildingId"></param> public static void DownloadRadioMap(int buildingId) { radiomapContext = new radiomapEntities(radiomapUri); buildings = new DataServiceCollection<Building>(radiomapContext); String expandOptions = "Building_Floors,Vertices,Vertices/AbsoluteLocations,Vertices/SymbolicLocations,Vertices/Edges,Edges,Edges/Vertices,Edges/Vertices/AbsoluteLocations"; var query = from b in radiomapContext.Buildings.Expand(expandOptions) where b.ID == buildingId select b; // Register for the LoadCompleted event. buildings.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(buildings_LoadCompleted); buildings.LoadAsync(query); }
private void LoadRuntimeData() { NetflixCatalog catalog = new NetflixCatalog(new Uri("http://odata.netflix.com/Catalog", UriKind.Absolute)); _items = new DataServiceCollection<Title>(catalog); _items.LoadAsync(new Uri("/Titles?$top=25&$filter=Rating eq 'PG' and ReleaseYear eq 1983&$orderby=AverageRating desc", UriKind.Relative)); }
private void ShowDebtCalculations() { ButtonList.Children.Add(new ProgressBar { IsIndeterminate = true, Width = 300, Margin = new Thickness(0, 30, 0, 0) }); _container = ApiHelper.GetContainer(); _calculations = new DataServiceCollection<DebtCalculation>(_container); var query = _container.DebtCalculations.OrderByDescending(dc => dc.LastActivityTime); _calculations.LoadCompleted += BuildButtonList; _calculations.LoadAsync(query); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (totalParticipants != 0) // Page already loaded return; id = long.Parse(NavigationContext.QueryString["debtCalculationId"]); _container = ApiHelper.GetContainer(); _participants = new DataServiceCollection<Participant>(_container); // Cannot localize ApplicationBar unless it is created in code behind ApplicationBar = new ApplicationBar { BackgroundColor = Color.FromArgb(255, 0x86, 0xC4, 0x40), //"#86C440" Opacity = 1, ForegroundColor = Colors.White }; ContentPanel.Children.Add(new ProgressBar { IsIndeterminate = true, Width = 300, Margin = new Thickness(0, 30, 0, 0) }); var query = _container.Participants .Expand(p => p.User) .Where(p => p.DebtCalculation.Id == id); _participants.LoadCompleted += ShowExpenseParticipants; _participants.LoadAsync(query); }