-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathUC10CreateHugeAmountOfDemoEntries.cs
More file actions
44 lines (36 loc) · 1.33 KB
/
UC10CreateHugeAmountOfDemoEntries.cs
File metadata and controls
44 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CoreHelpers.WindowsAzure.Storage.Table.Demo.Contracts;
using CoreHelpers.WindowsAzure.Storage.Table.Demo.Helpers;
using CoreHelpers.WindowsAzure.Storage.Table.Demo.Models;
namespace CoreHelpers.WindowsAzure.Storage.Table.Demo.DemoCases
{
public class UC10CreateHugeAmountOfDemoEntries : IDemoCase
{
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 < 20000; 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();
}
}
}
}