public async Task Execute(string storageKey, string storageSecret, string endpointSuffix = null)
		{
			Console.WriteLine("");
			Console.WriteLine(this.GetType().FullName);
			
			using (var storageContext = new StorageContext(storageKey, storageSecret, endpointSuffix))
			{
				// set our delegate 
				var stats = new DemoCaseStatsDelegate();
				storageContext.SetDelegate(stats);
				
				// ensure we are using the attributes
				storageContext.AddAttributeMapper(typeof(HugeDemoEntry));

				// create 2000 items
				var data = new List<HugeDemoEntry>();
				for (int i = 0; i < 2000; i++)
					data.Add(new HugeDemoEntry());

				await storageContext.EnableAutoCreateTable().MergeOrInsertAsync<HugeDemoEntry>(data);
				
				// query all entries
				var items = await storageContext.QueryAsync<HugeDemoEntry>();

				// remove all entries
				await storageContext.DeleteAsync<HugeDemoEntry>(items);

				// dump stats				
				stats.DumpStats();
			}
		}
Ejemplo n.º 2
0
        public async Task Execute(string storageKey, string storageSecret, string endpointSuffix = null)
        {
            Console.WriteLine("");
            Console.WriteLine(this.GetType().FullName);

            using (var storageContext = new StorageContext(storageKey, storageSecret, endpointSuffix))
            {
                // set the delegate
                var stats = new DemoCaseStatsDelegate();
                storageContext.SetDelegate(stats);

                // create a new user
                var user = new UserModel2()
                {
                    FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                };
                var vpmodel = new VirtualPartKeyDemoModel()
                {
                    Value1 = "abc", Value2 = "def", Value3 = "ghi"
                };

                // ensure we are using the attributes
                Console.WriteLine("Configuring Entity Mappers");
                storageContext.AddAttributeMapper(typeof(UserModel2));
                storageContext.AddAttributeMapper(typeof(VirtualPartKeyDemoModel));

                // ensure the table exists
                Console.WriteLine("Create Tables");
                await storageContext.CreateTableAsync <UserModel2>();

                await storageContext.CreateTableAsync <VirtualPartKeyDemoModel>();

                // inser the model
                Console.WriteLine("Insert Models");
                await storageContext.MergeOrInsertAsync <UserModel2>(user);

                await storageContext.MergeOrInsertAsync <VirtualPartKeyDemoModel>(vpmodel);

                // query all
                Console.WriteLine("Query all Models");
                var result = await storageContext.QueryAsync <UserModel2>();

                var resultVP = await storageContext.QueryAsync <VirtualPartKeyDemoModel>();

                foreach (var r in result)
                {
                    Console.WriteLine(r.FirstName);
                }

                // Clean up
                Console.WriteLine("Removing all entries");
                await storageContext.DeleteAsync <UserModel2>(result);

                await storageContext.DeleteAsync <VirtualPartKeyDemoModel>(resultVP);

                // dump the stats
                stats.DumpStats();
            }
        }
Ejemplo n.º 3
0
        public async Task Execute(string storageKey, string storageSecret, string endpointSuffix = null)
        {
            Console.WriteLine("");
            Console.WriteLine(this.GetType().FullName);

            using (var storageContext = new StorageContext(storageKey, storageSecret, endpointSuffix))
            {
                // set the delegate
                var stats = new DemoCaseStatsDelegate();
                storageContext.SetDelegate(stats);

                // create a virtual array model
                var model = new VArrayModel()
                {
                    UUID = "112233"
                };
                model.DataElements.Add(2);
                model.DataElements.Add(3);
                model.DataElements.Add(4);

                // ensure we are using the attributes
                Console.WriteLine("Configuring Entity Mappers");
                storageContext.AddAttributeMapper(typeof(VArrayModel));

                // ensure the table exists
                Console.WriteLine("Create Tables");
                await storageContext.CreateTableAsync <VArrayModel>();

                // inser the model
                Console.WriteLine("Insert Models");
                await storageContext.MergeOrInsertAsync <VArrayModel>(model);

                // query all
                Console.WriteLine("Query all Models");
                var result = await storageContext.QueryAsync <VArrayModel>();

                foreach (var r in result)
                {
                    Console.WriteLine(r.UUID);

                    foreach (var e in r.DataElements)
                    {
                        Console.WriteLine(e);
                    }
                }

                // Clean up
                Console.WriteLine("Removing all entries");
                await storageContext.DeleteAsync <VArrayModel>(result);

                // dump the stats
                stats.DumpStats();
            }
        }
        public async Task Execute(string storageKey, string storageSecret, string endpointSuffix = null)
        {
            Console.WriteLine("");
            Console.WriteLine(this.GetType().FullName);

            using (var storageContext = new StorageContext(storageKey, storageSecret, endpointSuffix))
            {
                // set the delegate
                var stats = new DemoCaseStatsDelegate();
                storageContext.SetDelegate(stats);

                // create a new user
                Console.WriteLine("Build Models");
                var user01 = new UserModel3()
                {
                    FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                };
                var user02 = new UserModel3()
                {
                    FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                };
                user02.Codes.Add(new Code()
                {
                    CodeType = "x1", CodeValue = "x2"
                });
                user02.Codes.Add(new Code()
                {
                    CodeType = "x3", CodeValue = "x4"
                });

                Console.WriteLine("Configuring Entity Mappers");
                storageContext.AddAttributeMapper(typeof(UserModel3));

                Console.WriteLine("InsertData");
                await storageContext.EnableAutoCreateTable().MergeOrInsertAsync <UserModel3>(user01);

                await storageContext.EnableAutoCreateTable().MergeOrInsertAsync <UserModel3>(user02);

                Console.WriteLine("Query Data");
                var result = await storageContext.QueryAsync <UserModel3>();

                foreach (var r in result)
                {
                    Console.WriteLine("{0}: {1}", r.LastName, r.Codes.Count());
                }

                // Clean up
                Console.WriteLine("Removing all entries");
                await storageContext.DeleteAsync <UserModel3>(result);

                // dump the stats
                stats.DumpStats();
            }
        }
Ejemplo n.º 5
0
        private async Task AutoCreateDuringStore(string storageKey, string storageSecret, string endpointSuffix = null)
        {
            using (var storageContext = new StorageContext(storageKey, storageSecret, endpointSuffix))
            {
                // set the delegate
                var stats = new DemoCaseStatsDelegate();
                storageContext.SetDelegate(stats);

                // create a new user
                var user = new UserModel()
                {
                    FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                };

                // generate tablename
                Console.WriteLine("Generating Tablename");
                var tableName = "T" + Guid.NewGuid().ToString();
                tableName = tableName.Replace("-", "");

                // ensure we are using the attributes
                Console.WriteLine("Configuring Entity Mappers");
                storageContext.AddEntityMapper(typeof(UserModel), new DynamicTableEntityMapper()
                {
                    TableName = tableName, PartitionKeyFormat = "Contact", RowKeyFormat = "Contact"
                });

                // inser the model
                Console.WriteLine("Insert Models with auto table creation");
                await storageContext.EnableAutoCreateTable().MergeOrInsertAsync <UserModel>(user);

                // query all
                Console.WriteLine("Query all Models");
                var result = await storageContext.QueryAsync <UserModel>();

                foreach (var r in result)
                {
                    Console.WriteLine(r.LastName);
                }

                // Clean up
                Console.WriteLine("Removing all entries");
                await storageContext.DeleteAsync <UserModel>(result);

                // dump the stats
                stats.DumpStats();
            }
        }
        public async Task Execute(string storageKey, string storageSecret, string endpointSuffix = null)
        {
            Console.WriteLine("");
            Console.WriteLine(this.GetType().FullName);

            using (var storageContext = new StorageContext(storageKey, storageSecret, endpointSuffix))
            {
                // set our delegate
                var stats = new DemoCaseStatsDelegate();
                storageContext.SetDelegate(stats);

                // ensure we are using the attributes
                storageContext.AddAttributeMapper(typeof(HugeDemoEntry));

                // create 4000 items
                Console.WriteLine("Creating 4200 demos items");
                var data = new List <HugeDemoEntry>();
                for (int i = 0; i < 4200; i++)
                {
                    data.Add(new HugeDemoEntry());
                }

                await storageContext.EnableAutoCreateTable().MergeOrInsertAsync <HugeDemoEntry>(data);

                // query items page by page
                Console.WriteLine("Reading page by page");

                var items = new List <HugeDemoEntry>();

                using (var queryCursor = storageContext.QueryPaged <HugeDemoEntry>(null, null))
                {
                    while (await queryCursor.LoadNextPageAsync())
                    {
                        Console.WriteLine("Reading Page #{0} with #{1} items", queryCursor.Page, queryCursor.Items.Count());
                        items.AddRange(queryCursor.Items);
                    }
                }

                // remove all entries
                Console.WriteLine("Removing all entries");
                await storageContext.DeleteAsync <HugeDemoEntry>(items);

                // dump stats
                stats.DumpStats();
            }
        }
Ejemplo n.º 7
0
        public async Task Execute(string storageKey, string storageSecret, string endpointSuffix = null)
        {
            Console.WriteLine("");
            Console.WriteLine(this.GetType().FullName);

            using (var storageContext = new StorageContext(storageKey, storageSecret, endpointSuffix))
            {
                // set the delegate
                var stats = new DemoCaseStatsDelegate();
                storageContext.SetDelegate(stats);

                Console.WriteLine("Configuring Entity Mappers");
                storageContext.AddAttributeMapper(typeof(UserModel2), "DemoUserModel2");

                Console.WriteLine("Create Tables");
                storageContext.CreateTable <UserModel2>(true);

                Console.WriteLine("InsertData");
                var data = new List <UserModel2>()
                {
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    },
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    },
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    },
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    },
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    },
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    },
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    },
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    },
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    },
                    new UserModel2()
                    {
                        FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                    }
                };

                await storageContext.StoreAsync(nStoreOperation.mergeOrInserOperation, data);


                Console.WriteLine("Query max Item Models");
                var items = (await storageContext.QueryAsync <UserModel2>(5)).AsEnumerable();
                Console.WriteLine("Found {0} items", items.Count());
                if (items.Count() != 5)
                {
                    Console.WriteLine("OHOH should be 5");
                }

                Console.WriteLine("Query all items");
                var allitems = await storageContext.QueryAsync <UserModel2>();

                // Clean up
                Console.WriteLine("Removing all entries");
                await storageContext.DeleteAsync <UserModel2>(allitems);

                // dump the stats
                stats.DumpStats();
            }
        }
Ejemplo n.º 8
0
        public async Task Execute(string storageKey, string storageSecret, string endpointSuffix = null)
        {
            Console.WriteLine("");
            Console.WriteLine(this.GetType().FullName);

            using (var storageContextParent = new StorageContext(storageKey, storageSecret, endpointSuffix))
            {
                // set the delegate
                var stats = new DemoCaseStatsDelegate();
                storageContextParent.SetDelegate(stats);

                // create a new user
                var user = new UserModel()
                {
                    FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**"
                };
                user.Contact = user.Contact + Guid.NewGuid().ToString();

                var vpmodel = new VirtualPartitionKeyDemoModelPOCO()
                {
                    Value1 = "abc", Value2 = "def", Value3 = "ghi"
                };

                // configure the entity mapper
                Console.WriteLine("Configuring Entity Mappers");
                storageContextParent.AddEntityMapper(typeof(UserModel), new DynamicTableEntityMapper()
                {
                    TableName = "UserProfiles", PartitionKeyFormat = "Contact", RowKeyFormat = "Contact"
                });
                storageContextParent.AddEntityMapper(typeof(VirtualPartitionKeyDemoModelPOCO), new DynamicTableEntityMapper()
                {
                    TableName = "VirtualPartitionKeyDemoModelPOCO", PartitionKeyFormat = "{{Value1}}-{{Value2}}", RowKeyFormat = "{{Value2}}-{{Value3}}"
                });

                using (var storageContext = new StorageContext(storageContextParent))
                {
                    // ensure the table exists
                    Console.WriteLine("Create Tables");
                    await storageContext.CreateTableAsync <UserModel>();

                    await storageContext.CreateTableAsync <VirtualPartitionKeyDemoModelPOCO>();

                    // inser the model
                    Console.WriteLine("Insert Models");
                    await storageContext.MergeOrInsertAsync <UserModel>(user);

                    await storageContext.MergeOrInsertAsync <VirtualPartitionKeyDemoModelPOCO>(vpmodel);
                }

                // query all
                Console.WriteLine("Query all Models");
                var result = await storageContextParent.QueryAsync <UserModel>();

                var resultVP = await storageContextParent.QueryAsync <VirtualPartitionKeyDemoModelPOCO>();

                foreach (var r in result)
                {
                    Console.WriteLine(r.FirstName);
                }

                // Clean up
                Console.WriteLine("Removing all entries");
                await storageContextParent.DeleteAsync <UserModel>(result);

                await storageContextParent.DeleteAsync <VirtualPartitionKeyDemoModelPOCO>(resultVP);

                // dump the stats
                stats.DumpStats();
            }
        }
        public async Task Execute(string storageKey, string storageSecret, string endpointSuffix = null)
        {
            Console.WriteLine("");
            Console.WriteLine(this.GetType().FullName);

            using (var storageContext = new StorageContext(storageKey, storageSecret, endpointSuffix))
            {
                // set the delegate
                var stats = new DemoCaseStatsDelegate();
                storageContext.SetDelegate(stats);

                // ensure we are using the attributes
                Console.WriteLine("Configuring Entity Mappers");
                storageContext.AddAttributeMapper(typeof(UserModel2), "DemoUserModel2");

                // create tables
                Console.WriteLine("Create Tables");
                await storageContext.CreateTableAsync <UserModel2>(true);

                // write data pages
                Console.WriteLine("Writing Models Paged");
                var startDate = DateTime.Now;


                using (var pagedWriter = new PagedTableEntityWriter <UserModel2>(storageContext, nStoreOperation.insertOrReplaceOperation, 100))
                {
                    var t1 = Task.Run(async() =>
                    {
                        for (var i = 0; i < 500; i++)
                        {
                            var user = new UserModel2()
                            {
                                FirstName = "Egon", LastName = "Mueller", Contact = string.Format("em-{0}@acme.org", i)
                            };
                            await pagedWriter.StoreAsync(user);
                        }
                    });

                    var t2 = Task.Run(async() =>
                    {
                        for (var i = 500; i < 1000; i++)
                        {
                            var user = new UserModel2()
                            {
                                FirstName = "Egon", LastName = "Mueller", Contact = string.Format("em-{0}@acme.org", i)
                            };
                            await pagedWriter.StoreAsync(user);
                        }
                    });

                    Task.WaitAll(new Task[] { t1, t2 });
                }

                var endDate = DateTime.Now;

                Console.WriteLine("Took {0} seconds", (endDate - startDate).TotalSeconds);

                // query all
                Console.WriteLine("Query all Models");
                var result = await storageContext.QueryAsync <UserModel2>();

                Console.WriteLine("Found {0} models", result.Count());

                // Clean up
                Console.WriteLine("Removing all entries");
                await storageContext.DeleteAsync <UserModel2>(result);

                // dump the stats
                stats.DumpStats();
            }
        }