public static void Run() { Console.WriteLine("Connecting to SQL Document Store..."); var monkies = new SQLDocumentList <Monkey>("northwind"); monkies.Clear(); var sw = new Stopwatch(); sw.Start(); var addRange = new List <Monkey>(); for (int i = 0; i < 10000; i++) { addRange.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } var inserted = monkies.AddRange(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", inserted, sw.ElapsedMilliseconds); Console.WriteLine("Loading 100,000 documents"); sw.Reset(); addRange.Clear(); monkies.Clear(); sw.Start(); for (int i = 0; i < 100000; i++) { addRange.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } inserted = monkies.AddRange(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", inserted, sw.ElapsedMilliseconds); //use a DB that has an int PK sw.Reset(); sw.Start(); Console.WriteLine("Loading {0}...", inserted); monkies.Reload(); sw.Stop(); Console.WriteLine("Loaded {0} documents from SQL Server in {1}ms", inserted, sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); Console.WriteLine("Querying Middle 100 Documents"); var found = monkies.Where(x => x.ID > 100 && x.ID < 500); sw.Stop(); Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds); }
public void CreatesSerialPK() { var actors = new SQLDocumentList <Actor>("northwind"); actors.Clear(); var newActor = new Actor { First_Name = "Joe", Last_Name = "Blow" }; actors.Add(newActor); int newId = newActor.Actor_ID; actors.Reload(); Assert.True(actors.Any(a => a.Actor_ID == newId)); }
public static void Run() { Console.WriteLine("==========================================================="); Console.WriteLine("SQL SERVER - LOAD A BUNCH OF DOCUMENTS INTO A TABLE"); Console.WriteLine("==========================================================="); Console.WriteLine("Connecting to SQL Document Store..."); // Start clean and fresh . . . if (Benchmarks.TableExists("clientdocuments")) { Benchmarks.DropTable("clientdocuments"); } var _clientDocuments = new SQLDocumentList<ClientDocument>(_connectionStringName); _clientDocuments.Clear(); var sw = new Stopwatch(); var addRange = new List<ClientDocument>(); for (int i = 0; i < 10000; i++) { addRange.Add(new ClientDocument { LastName = "Conery " + i, FirstName = "Rob", Email = "*****@*****.**" }); } sw.Start(); var inserted = _clientDocuments.AddRange(addRange); sw.Stop(); Console.WriteLine("\t Just inserted {0} as documents in {1} ms", inserted, sw.ElapsedMilliseconds); // Start clean and fresh again . . . _clientDocuments.Clear(); addRange.Clear(); Benchmarks.DropTable("clientdocuments"); _clientDocuments = new SQLDocumentList<ClientDocument>(_connectionStringName); sw.Reset(); Console.WriteLine("Loading 100,000 documents"); for (int i = 0; i < 100000; i++) { addRange.Add(new ClientDocument { LastName = "Conery " + i, FirstName = "Rob", Email = "*****@*****.**" }); } sw.Start(); inserted = _clientDocuments.AddRange(addRange); sw.Stop(); Console.WriteLine("\t Just inserted {0} as documents in {1} ms", inserted, sw.ElapsedMilliseconds); //use a DB that has an int PK sw.Reset(); Console.WriteLine("Loading {0}...", inserted); sw.Start(); _clientDocuments.Reload(); sw.Stop(); Console.WriteLine("\t Loaded {0} documents from SQL Server in {1} ms", inserted, sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Querying Middle 100 Documents"); sw.Start(); var found = _clientDocuments.Where(x => x.ClientDocumentId > 100 && x.ClientDocumentId < 500); sw.Stop(); Console.WriteLine("\t Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Adds Items in a loop, follows by Bulk Insert"); if (TableExists("items")) { DropTable("items"); } sw.Start(); var list = new List<Item>(); for (int i = 1; i < 6; i++) { list.Add(new Item() { Name = "Item no " + i }); } var items = new SQLDocumentList<Item>("chinook"); // 1. Add items in a loop foreach (var item in list) { items.Add(item); } // 2. Add items using AddRange... items.AddRange(list); sw.Stop(); Console.WriteLine("\t Added {0} items in a loop, then added same items as bullk insert in {1}", list.Count(), sw.ElapsedMilliseconds); }
public static void Run() { Console.WriteLine("==========================================================="); Console.WriteLine("SQL SERVER - LOAD A BUNCH OF DOCUMENTS INTO A TABLE"); Console.WriteLine("==========================================================="); Console.WriteLine("Connecting to SQL Document Store..."); // Start clean and fresh . . . if(Benchmarks.TableExists("clientdocuments")) { Benchmarks.DropTable("clientdocuments"); } var _clientDocuments = new SQLDocumentList<ClientDocument>(_connectionStringName); _clientDocuments.Clear(); var sw = new Stopwatch(); var addRange = new List<ClientDocument>(); for (int i = 0; i < 10000; i++) { addRange.Add(new ClientDocument { LastName = "Conery " + i, FirstName = "Rob", Email = "*****@*****.**" }); } sw.Start(); var inserted = _clientDocuments.AddRange(addRange); sw.Stop(); Console.WriteLine("\t Just inserted {0} as documents in {1} ms", inserted, sw.ElapsedMilliseconds); // Start clean and fresh again . . . _clientDocuments.Clear(); addRange.Clear(); Benchmarks.DropTable("clientdocuments"); _clientDocuments = new SQLDocumentList<ClientDocument>(_connectionStringName); sw.Reset(); Console.WriteLine("Loading 100,000 documents"); for (int i = 0; i < 100000; i++) { addRange.Add(new ClientDocument { LastName = "Conery " + i, FirstName = "Rob", Email = "*****@*****.**" }); } sw.Start(); inserted = _clientDocuments.AddRange(addRange); sw.Stop(); Console.WriteLine("\t Just inserted {0} as documents in {1} ms", inserted, sw.ElapsedMilliseconds); //use a DB that has an int PK sw.Reset(); Console.WriteLine("Loading {0}...", inserted); sw.Start(); _clientDocuments.Reload(); sw.Stop(); Console.WriteLine("\t Loaded {0} documents from SQL Server in {1} ms", inserted, sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Querying Middle 100 Documents"); sw.Start(); var found = _clientDocuments.Where(x => x.ClientDocumentId > 100 && x.ClientDocumentId < 500); sw.Stop(); Console.WriteLine("\t Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds); }