static void CreateModelsPaged(string storageKey, string storageSecret) { using (var storageContext = new StorageContext(storageKey, storageSecret)) { storageContext.AddAttributeMapper(typeof(UserModel2), "DemoUserModel2"); storageContext.CreateTable <UserModel2>(true); var startDate = DateTime.Now; using (var pagedWriter = new PagedTableEntityWriter <UserModel2>(storageContext, nStoreOperation.insertOrReplaceOperation, 100)) { for (var i = 0; i < 1000; i++) { var user = new UserModel2() { FirstName = "Egon", LastName = "Mueller", Contact = string.Format("em-{0}@acme.org", i) }; pagedWriter.StoreAsync(user).ConfigureAwait(false).GetAwaiter().GetResult(); } } var endDate = DateTime.Now; Console.WriteLine("Took {0} seconds", (endDate - startDate).TotalSeconds); } }
static void StorageWithAttributeMapper(string storageKey, string storageSecret) { // create a new user var user = new UserModel2() { FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**" }; using (var storageContext = new StorageContext(storageKey, storageSecret)) { // ensure we are using the attributes storageContext.AddAttributeMapper(); // ensure the table exists storageContext.CreateTable <UserModel2>(); // inser the model storageContext.MergeOrInsert <UserModel2>(user); // query all var result = storageContext.Query <UserModel2>(); foreach (var r in result) { Console.WriteLine(r.FirstName); } } }
static void StorageWithAttributeMapperManualRegistration(string storageKey, string storageSecret) { // create a new user var user = new UserModel2() { FirstName = "Egon", LastName = "Mueller", Contact = "*****@*****.**" }; var vpmodel = new VirtualPartKeyDemoModel() { Value1 = "abc", Value2 = "def", Value3 = "ghi" }; using (var storageContext = new StorageContext(storageKey, storageSecret)) { // ensure we are using the attributes storageContext.AddAttributeMapper(typeof(UserModel2)); storageContext.AddAttributeMapper(typeof(VirtualPartKeyDemoModel)); // ensure the table exists storageContext.CreateTable <UserModel2>(); storageContext.CreateTable <VirtualPartKeyDemoModel>(); // inser the model storageContext.MergeOrInsert <UserModel2>(user); storageContext.MergeOrInsert <VirtualPartKeyDemoModel>(vpmodel); // query all var result = storageContext.Query <UserModel2>(); foreach (var r in result) { Console.WriteLine(r.FirstName); } } }