Example #1
0
 private async void btnInsertComplexClientSide_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var rnd = new Random();
         var template = Movies_Client[rnd.Next(Movies_Client.Length)];
         var movieToInsert = new Movie_ComplexClientSide
         {
             Title = template.Title,
             ReleaseYear = template.ReleaseYear,
             Reviews = Enumerable.Range(0, rnd.Next(2) + 1).Select(_ => SampleReviews[rnd.Next(SampleReviews.Length)]).ToArray()
         };
         var table = MobileService.GetTable<Movie_ComplexClientSide>();
         await table.InsertAsync(movieToInsert);
         this.AddToDebug("Inserted movie {0} with id = {1}", movieToInsert.Title, movieToInsert.Id);
     }
     catch (Exception ex)
     {
         this.AddToDebug("Error: {0}", ex);
     }
 }
Example #2
0
        private async void btnInsertComplexClientSide_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var rnd           = new Random();
                var template      = Movies_Client[rnd.Next(Movies_Client.Length)];
                var movieToInsert = new Movie_ComplexClientSide
                {
                    Title       = template.Title,
                    ReleaseYear = template.ReleaseYear,
                    Reviews     = Enumerable.Range(0, rnd.Next(2) + 1).Select(_ => SampleReviews[rnd.Next(SampleReviews.Length)]).ToArray()
                };
                var table = MobileService.GetTable <Movie_ComplexClientSide>();
                await table.InsertAsync(movieToInsert);

                this.AddToDebug("Inserted movie {0} with id = {1}", movieToInsert.Title, movieToInsert.Id);
            }
            catch (Exception ex)
            {
                this.AddToDebug("Error: {0}", ex);
            }
        }