private static void DataServiceCollectionTrackingItems( DataServiceContextWrapper <DefaultContainer> contextWrapper) { var query = from p in contextWrapper.Context.Customer where p.CustomerId > -100000 // try to get many for paging select new Customer() { CustomerId = p.CustomerId, Name = p.Name }; DataServiceCollection <Customer> collection = new DataServiceCollection <Customer>(query); // the collection to track items int tmpCount = collection.Count; collection.Load(contextWrapper.Context.Execute(collection.Continuation)); // for testing newly loaded item's tracking Assert.IsTrue(collection.Count > tmpCount, "Should have loaded another page."); bool someItemNotTracked = false; collection.ToList().ForEach(s => { s.Name = "value to test tracking"; EntityStates state = contextWrapper.Context.GetEntityDescriptor(s).State; someItemNotTracked = (state == EntityStates.Unchanged) || someItemNotTracked; }); Assert.IsFalse(someItemNotTracked, "All items should have been tracked."); }
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); }
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); }
private static void DataServiceCollectionTrackingItems( DataServiceContextWrapper<DefaultContainer> contextWrapper) { var query = from p in contextWrapper.Context.Customer where p.CustomerId > -100000 // try to get many for paging select new Customer() { CustomerId = p.CustomerId, Name = p.Name }; DataServiceCollection<Customer> collection = new DataServiceCollection<Customer>(query); // the collection to track items int tmpCount = collection.Count; collection.Load(contextWrapper.Context.Execute(collection.Continuation)); // for testing newly loaded item's tracking Assert.IsTrue(collection.Count > tmpCount, "Should have loaded another page."); bool someItemNotTracked = false; collection.ToList().ForEach(s => { s.Name = "value to test tracking"; EntityStates state = contextWrapper.Context.GetEntityDescriptor(s).State; someItemNotTracked = (state == EntityStates.Unchanged) || someItemNotTracked; }); Assert.IsFalse(someItemNotTracked, "All items should have been tracked."); }
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)); }