Esempio n. 1
0
        public ActionResult AddDataToTest()
        {
            var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
            var context          = new CustomerDataContext(cloudStorageAccount.TableEndpoint.AbsoluteUri, cloudStorageAccount.Credentials);

            try
            {
                // 向表中添加65个实体
                for (int i = 0; i < 65; i++)
                {
                    context.AddObject("Customers", new Customer()
                    {
                        Age = r.Next(16, 70), Name = "Customer" + i.ToString()
                    });
                }
                context.SaveChanges();
                MVCSessionCachedDataProvider <Customer> provider      = new MVCSessionCachedDataProvider <Customer>(this, "provider1");
                TableStoragePagingUtility <Customer>    pagingUtility = new TableStoragePagingUtility <Customer>(provider, cloudStorageAccount,
                                                                                                                 context, 10, "Customers");
                return(View("Index", new CustomersSet()
                {
                    Customers = pagingUtility.GetNextPage().ToList(), ReadyToShowUI = true
                }));
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "HomeController", "AddDataToTest")));
            }
        }