public ActionResult FillWithDataDifferentPartitionKeys(int numberOfRows) { var sw = new Stopwatch(); sw.Start(); var account = GetAccountInfo(); var context = new TestContext(account.TableEndpoint.AbsoluteUri, account.Credentials); if (numberOfRows == 0) numberOfRows = 1000000; var entityList = new List<TestEntity>(); const int MAX_OBJECTS_IN_BATCH = 100; int objectsInBatch = 0; string partitionKey = "C"; for (int i = 0; i < numberOfRows; i++) { var id = Convert.ToBase64String(Guid.NewGuid().ToByteArray()).Replace("/", "-").Replace("+", "_").Replace("=", ""); var rowKey = (DateTime.MaxValue - DateTime.Now).Ticks.ToString("d19") + id; var entity = new TestEntity() { PartitionKey = partitionKey, RowKey = rowKey, FirstName = "John" + i.ToString(), LastName = "Doe" + i.ToString(), SomeId = id }; context.AddObject(TABLE_NAME, entity); if (++objectsInBatch == MAX_OBJECTS_IN_BATCH) { entityList.Add(entity); partitionKey += i.ToString(); objectsInBatch = 0; context.SaveChangesWithRetries(SaveChangesOptions.Batch); } } context.SaveChangesWithRetries(SaveChangesOptions.Batch); ViewData["Data"] = entityList; ViewData["Elapsed"] = sw.ElapsedMilliseconds; return View("Index"); }
public ActionResult QueryByRowKey(string rowKey) { var sw = new Stopwatch(); sw.Start(); var account = GetAccountInfo(); var context = new TestContext(account.TableEndpoint.AbsoluteUri, account.Credentials); var query = context.CreateQuery<TestEntity>(TABLE_NAME); var entity = query.Where(e => e.RowKey== rowKey).ToList(); //var entity = (from e in context.CreateQuery<TestEntity>(TABLE_NAME) where e.RowKey==rowKey select e); ViewData["Data"] = entity; ViewData["Elapsed"] = sw.ElapsedMilliseconds; return View("Index"); }
public ActionResult QueryByRowkeyAndPartitionKey(string partitionKey, string rowKey) { var sw = new Stopwatch(); sw.Start(); var account = GetAccountInfo(); var context = new TestContext(account.TableEndpoint.AbsoluteUri, account.Credentials); var query = context.CreateQuery<TestEntity>(TABLE_NAME); var entity = query.Where(e => e.PartitionKey.Equals(partitionKey) && e.RowKey.Equals(rowKey)).ToList(); ViewData["Data"] = entity; ViewData["Elapsed"] = sw.ElapsedMilliseconds; return View("Index"); }
public ActionResult QueryByLastNameColumn(string lastName) { var sw = new Stopwatch(); sw.Start(); var account = GetAccountInfo(); var context = new TestContext(account.TableEndpoint.AbsoluteUri, account.Credentials); var query = context.CreateQuery<TestEntity>(TABLE_NAME); var entity = query.Where(e => e.LastName == lastName).ToList(); ViewData["Data"] = entity; ViewData["Elapsed"] = sw.ElapsedMilliseconds; return View("Index"); }