IBiggy <Widget> CreateBiggyList() { var store = new MongoStore <Widget>(Host, Database, Collection); var list = new BiggyList <Widget>(store); return(list); }
public void Biggylist_Updates_Single_Item_In_Json_Store() { var propertyList = new BiggyList<Property>(_propertyStore); int initialCount = propertyList.Count; var newProperty = new Property { Id = 1, Name = "John's Luxury Apartments", Address = "2639 I St NW, Washington, D.C. 20037" }; propertyList.Add(newProperty); int addedItemId = newProperty.Id; // Just to be sure, reload from backing store and check what was added: propertyList = new BiggyList<Property>(_propertyStore); var addedProperty = propertyList.FirstOrDefault(p => p.Id == addedItemId); bool isAddedProperly = addedProperty.Name.Contains("John's Luxury"); // Now Update: string newName = "John's Low-Rent Apartments"; addedProperty.Name = newName; propertyList.Update(addedProperty); // Go fetch again: propertyList = new BiggyList<Property>(_propertyStore); addedProperty = propertyList.FirstOrDefault(p => p.Id == addedItemId); bool isUpdatedProperly = addedProperty.Name == newName; Assert.IsTrue(isAddedProperly && isUpdatedProperly); }
public void Updates_Item_With_OVerride_From_List_And_Store() { // Just in case: var overriddenClients = new BiggyList <Client>(new SQLServerStore <Client>(_hostDb)); overriddenClients.Clear(); // Add a new record: var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; overriddenClients.Add(newClient); int newId = newClient.ClientId; // Update the same record-by-id with a new instance. OverrideClient overrides Equals with the id: var updateMe = new Client() { ClientId = newId, LastName = "Appleseed", FirstName = "John", Email = "*****@*****.**" }; overriddenClients.Update(updateMe); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList <Client>(new SQLServerStore <Client>(_connectionStringName)); var updated = altClientList.FirstOrDefault(c => c.LastName == "Appleseed"); Assert.True(updated != null && updated.LastName == "Appleseed"); }
public override bool Add() { JsonStore<BOCountry> tbID = (JsonStore<BOCountry>)m_dbConn.CreateStoreFor<BOCountry>(); var boIdList = new BiggyList<BOCountry>(tbID); return base.Add(); }
public void Biggylist_Removes_All_Items_From_Sqlite_Store() { var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var myBatch = new List <PropertyDocument>(); int qtyToAdd = 10; for (int i = 0; i < qtyToAdd; i++) { myBatch.Add(new PropertyDocument { Name = "Marvin Gardens " + i, Address = i + " PropertyDocument Parkway, Portland, OR 97204" }); } PropertyDocumentList.Add(myBatch); // Re-load from back-end: PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int qtyAdded = PropertyDocumentList.Count; PropertyDocumentList.Clear(); // Delete: PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int remaining = PropertyDocumentList.Count; Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0); }
public void Biggylist_Removes_Single_Item_From_Json_Store() { var propertyList = new BiggyList <Property>(_propertyStore); int initialCount = propertyList.Count; var newProperty = new Property { Id = 1, Name = "John's High-End Apartments", Address = "16 Property Parkway, Portland, OR 97204" }; propertyList.Add(newProperty); int addedItemId = newProperty.Id; // Just to be sure, reload from backing store and check what was added: propertyList = new BiggyList <Property>(_propertyStore); var addedProperty = propertyList.FirstOrDefault(p => p.Id == addedItemId); bool isAddedProperly = addedProperty.Name.Contains("High-End"); int qtyAdded = propertyList.Count; // Delete: var foundProperty = propertyList.FirstOrDefault(); propertyList.Remove(foundProperty); propertyList = new BiggyList <Property>(_propertyStore); int remaining = propertyList.Count; Assert.IsTrue(isAddedProperly && qtyAdded == 1 && remaining == 0); }
public void BiggyList_Initializes_From_Empty_Table() { var PropertyDocumentStore = _db.CreateRelationalStoreFor <PropertyDocument>(); var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); Assert.True(PropertyDocumentList.Store != null && PropertyDocumentList.Count == 0); }
public void Biggylist_Removes_Range_Of_Items_From_SQLite_Store() { var propertyList = new BiggyList <Property>(_propertyStore); int initialCount = propertyList.Count; var myBatch = new List <Property>(); int qtyToAdd = 10; for (int i = 0; i < qtyToAdd; i++) { myBatch.Add(new Property { Name = "Boardwalk " + i, Address = i + " Property Parkway, Portland, OR 97204" }); } propertyList.Add(myBatch); // Re-load from back-end: propertyList = new BiggyList <Property>(_propertyStore); int qtyAdded = propertyList.Count; // Select 5 for deletion: int qtyToDelete = 5; var deleteThese = propertyList.Where(c => c.Id <= qtyToDelete); propertyList.Remove(deleteThese); // Delete: propertyList = new BiggyList <Property>(_propertyStore); int remaining = propertyList.Count; Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete); }
public void Biggylist_Updates_Range_Of_Items_In_Sqlite_Store() { var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var myBatch = new List <PropertyDocument>(); int qtyToAdd = 10; for (int i = 1; i <= qtyToAdd; i++) { myBatch.Add(new PropertyDocument { Name = "John's Luxury Townhomes" + i, Address = i + " PropertyDocument Parkway, Portland, OR 97204" }); } PropertyDocumentList.Add(myBatch); // Just to be sure, reload from backing store and check what was added: PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); int addedCount = PropertyDocumentList.Count; // Update each item: for (int i = 0; i < qtyToAdd; i++) { PropertyDocumentList.ElementAt(i).Name = "John's Low-Rent Brick Homes " + i; } PropertyDocumentList.Update(PropertyDocumentList.ToList()); // Reload, and check updated names: PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore); var updatedItems = PropertyDocumentList.Where(p => p.Name.Contains("Low-Rent Brick")); Assert.IsTrue(updatedItems.Count() == qtyToAdd); }
public void Biggylist_Updates_Range_Of_Items_In_Json_Store() { var propertyList = new BiggyList <Property>(_propertyStore); int initialCount = propertyList.Count; var myBatch = new List <Property>(); int qtyToAdd = 10; // This test uses an initial index value of 1 so taht there is a non-zero ID for the first item: for (int i = 1; i <= qtyToAdd; i++) { myBatch.Add(new Property { Id = i, Name = "John's Luxury Townhomes" + i, Address = i + " Property Parkway, Portland, OR 97204" }); } propertyList.Add(myBatch); // Just to be sure, reload from backing store and check what was added: propertyList = new BiggyList <Property>(_propertyStore); int addedCount = propertyList.Count; // Update each item: for (int i = 0; i < qtyToAdd; i++) { propertyList.ElementAt(i).Name = "John's Low-Rent Brick Homes " + i; } propertyList.Update(propertyList.ToList()); // Reload, and check updated names: propertyList = new BiggyList <Property>(_propertyStore); var updatedItems = propertyList.Where(p => p.Name.Contains("Low-Rent Brick")); Assert.IsTrue(updatedItems.Count() == qtyToAdd); }
public void Initializes_Memory_Only_List_With_True_Argument() { _biggyMemoryList = new BiggyList <Widget>(inMemory: true); var BiggyJsonList = new BiggyList <Widget>(); _biggyMemoryList.Clear(); BiggyJsonList.Clear(); var batch = new List <Widget>(); for (int i = 0; i < INSERT_QTY; i++) { batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i }); } _biggyMemoryList.Add(batch); BiggyJsonList.Add(batch); int memoryCount = _biggyMemoryList.Count(); _biggyMemoryList.Clear(); BiggyJsonList = new BiggyList <Widget>(); Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY); }
public void Biggylist_Removes_All_Items_From_Json_Store() { var propertyList = new BiggyList <Property>(_propertyStore); int initialCount = propertyList.Count; var myBatch = new List <Property>(); int qtyToAdd = 10; for (int i = 0; i < qtyToAdd; i++) { myBatch.Add(new Property { Id = i, Name = "Marvin Gardens " + i, Address = i + " Property Parkway, Portland, OR 97204" }); } propertyList.Add(myBatch); // Re-load from back-end: propertyList = new BiggyList <Property>(_propertyStore); int qtyAdded = propertyList.Count; propertyList.Clear(); // Delete: propertyList = new BiggyList <Property>(_propertyStore); int remaining = propertyList.Count; Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0); }
public DownloadRecord InitDownload(DownloadRecord downloadRecord) { lock (JsonStore) { var dRecords = new BiggyList <DownloadRecord>(JsonStore); var dr = dRecords.FirstOrDefault(a => a.Url == downloadRecord.Url); if (dr == null) { if (downloadRecord.DownloadItem == null) { downloadRecord.DownloadItem = new DownloadItem() { IsComplete = false }; } dRecords.Add(downloadRecord); dr = downloadRecord; } else { dr.IsCancelled = downloadRecord.IsCancelled; } dr.Hash = GetHashString(downloadRecord.Url); var finalFolder = EnsurePath(dr.Hash); var fullPath = Path.Combine(finalFolder, dr.FileName); dr.FullPath = fullPath; dRecords.Update(dr); return(dr); } }
public override bool TryGetMember(GetMemberBinder binder, out object result) { //return base.TryGetMember(binder, out result); _existing = _existing ?? new BiggyList<dynamic>(dbName: binder.Name); result = _existing; return true; }
public void Removes_Many_Items_From_List_And_Store() { int INSERT_QTY = 10; // Just in case: _clients.Clear(); var addThese = new List <Client>(); for (int i = 0; i < INSERT_QTY; i++) { var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" }; addThese.Add(newClient); } _clients.Add(addThese); // Open a new instance, to see if the item was added to the backing store as well: var altClientArray = new BiggyList <Client>(new PGStore <Client>(_connectionStringName)).ToArray(); var removeThese = new List <Client>(); for (int i = 0; i < 5; i++) { removeThese.Add(altClientArray[i]); } _clients.Remove(removeThese); // Reload the list: _clients = new BiggyList <Client>(new PGStore <Client>(_connectionStringName)); Assert.True(_clients.Count() == (INSERT_QTY - removeThese.Count())); }
public void PurgeIncompletes() { lock (JsonStore) { var updateList = new List <DownloadRecord>(); var dRecords = new BiggyList <DownloadRecord>(JsonStore); foreach (var item in dRecords) { if (item.DownloadItem == null) { continue; } if (item.DownloadItem.IsComplete) { continue; } if (item.DownloadItem.IsInProgress) { File.Delete(item.DownloadItem.FullPath); item.DownloadItem = new DownloadItem() { IsComplete = false }; updateList.Add(item);; } } foreach (var item in updateList) { dRecords.Update(item); } } }
public void Biggylist_Updates_Single_Item_In_Json_Store() { var propertyList = new BiggyList <Property>(_propertyStore); int initialCount = propertyList.Count; var newProperty = new Property { Id = 1, Name = "John's Luxury Apartments", Address = "2639 I St NW, Washington, D.C. 20037" }; propertyList.Add(newProperty); int addedItemId = newProperty.Id; // Just to be sure, reload from backing store and check what was added: propertyList = new BiggyList <Property>(_propertyStore); var addedProperty = propertyList.FirstOrDefault(p => p.Id == addedItemId); bool isAddedProperly = addedProperty.Name.Contains("John's Luxury"); // Now Update: string newName = "John's Low-Rent Apartments"; addedProperty.Name = newName; propertyList.Update(addedProperty); // Go fetch again: propertyList = new BiggyList <Property>(_propertyStore); addedProperty = propertyList.FirstOrDefault(p => p.Id == addedItemId); bool isUpdatedProperly = addedProperty.Name == newName; Assert.IsTrue(isAddedProperly && isUpdatedProperly); }
static void Main(string[] args) { var store = new JsonStore <Item>("dbDirectory", "dbName", "itemTable"); var items = new BiggyList <Item>(store); //items.Add(new Item { Id = 1, Name = "item one" }); //items.Add(new Item { Id = 2, Name = "item two" }); //items.Contains() foreach (var item in items) { WriteLine($"{item.Id} - {item.Name}"); } var contains = items.Contains(new Item { Id = 1, Name = "item one" }); WriteLine("Contains: " + contains); var firstOrDefault = items.FirstOrDefault(i => i.Id == 1); WriteLine("FirstOrDefault: " + firstOrDefault.Name); ReadLine(); }
public virtual void LoadData() { this.Artists = new BiggyList <Artist>(CreateRelationalStoreFor <Artist>()); this.Albums = new BiggyList <Album>(CreateRelationalStoreFor <Album>()); this.Tracks = new BiggyList <Track>(CreateRelationalStoreFor <Track>()); this.ArtistDocuments = new BiggyList <ArtistDocument>(CreateDocumentStoreFor <ArtistDocument>()); }
public void BiggyList_Initializes_From_Empty_Table() { var propertyStore = _db.CreateRelationalStoreFor <Property>(); var propertyList = new BiggyList <Property>(_propertyStore); Assert.True(propertyList.Store != null && propertyList.Count == 0); }
public void Biggylist_Adds_Range_Of_Items_To_Json_Store() { var propertyList = new BiggyList <Property>(_propertyStore); int initialCount = propertyList.Count; var myBatch = new List <Property>(); int qtyToAdd = 10; // This test uses an initial index value of 1 so taht there is a non-zero ID for the first item: for (int i = 1; i <= qtyToAdd; i++) { var newProperty = new Property { Id = i, Name = "New Apartment " + i, Address = "Some Street in a Lonely Town" }; myBatch.Add(newProperty); } propertyList.Add(myBatch); // Reload from the store: propertyList = new BiggyList <Property>(_propertyStore); var addedItems = propertyList.FirstOrDefault(p => p.Name.Contains("New Apartment")); Assert.IsTrue(initialCount == 0 && propertyList.Count == qtyToAdd); }
public void Dispose() { if (CurrentList == null) return; CurrentList.Clear(); CurrentList = null; }
public override bool TryGetMember(GetMemberBinder binder, out object result) { //return base.TryGetMember(binder, out result); CurrentList = CurrentList ?? new BiggyList<dynamic>(dbName: binder.Name); result = CurrentList; return true; }
public void Biggylist_Removes_Range_Of_Items_From_Json_Store() { var propertyList = new BiggyList <Property>(_propertyStore); int initialCount = propertyList.Count; var myBatch = new List <Property>(); int qtyToAdd = 10; // This test uses an initial index value of 1 so taht there is a non-zero ID for the first item: for (int i = 1; i <= qtyToAdd; i++) { myBatch.Add(new Property { Id = i, Name = "Boardwalk " + i, Address = i + " Property Parkway, Portland, OR 97204" }); } propertyList.Add(myBatch); // Re-load from back-end: propertyList = new BiggyList <Property>(_propertyStore); int qtyAdded = propertyList.Count; // Select 5 for deletion: int qtyToDelete = 5; var deleteThese = propertyList.Where(c => c.Id <= qtyToDelete); propertyList.Remove(deleteThese); // Delete: propertyList = new BiggyList <Property>(_propertyStore); int remaining = propertyList.Count; Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete); }
void RunBenchmarks() { Console.WriteLine("Writing 1000 records sync"); var sw = new Stopwatch(); var products = new BiggyList<Product>(); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.Save(); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Resetting..."); products.ClearAndSave(); Console.WriteLine("Writing 1000 records async"); //1000 writes? for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKUDDY" + i, Name = "Steve", Price = 12.00M }; products.Add(p); } sw.Start(); products.SaveAsync(); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); //1000 writes? Console.WriteLine("Writing 1000 records with write happening in a loop"); sw.Start(); for (int i = 0; i < 1000; i++) { var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M }; products.Add(p); //bad idea... run it and see why products.Save(); } sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Reading from records"); sw.Start(); var p2 = products.Where(x => x.Sku == "SKU22").FirstOrDefault(); Console.WriteLine(p2.Sku); sw.Stop(); Console.WriteLine("{0}ms", sw.ElapsedMilliseconds); Console.Read(); }
public static void Run() { Console.WriteLine("Loading from File Store..."); var clients = new BiggyList <Client>(new JsonStore <Client>("clients")); clients.Clear(); var sw = new Stopwatch(); // Write a modest-sized batch to a file: int SMALL_BATCH_QTY = 1000; Console.WriteLine("Write {0} documents", SMALL_BATCH_QTY); var addRange = new List <Client>(); for (int i = 0; i < SMALL_BATCH_QTY; i++) { addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clients.Add(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds); int LARGE_BATCH_QTY = 100000; Console.WriteLine("Write {0} documents", LARGE_BATCH_QTY); sw.Reset(); clients.Clear(); // Write a Bigger-sized batch to a file: // Reset the temp List; addRange = new List <Client>(); for (int i = 0; i < LARGE_BATCH_QTY; i++) { addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clients.Add(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); Console.WriteLine("Querying Middle 400 Documents"); var found = clients.Where(x => x.ClientId > 100 && x.ClientId < 500); sw.Stop(); Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds); }
public DownloadRecord GetDownloadRecord(string url) { lock (JsonStore) { var dRecords = new BiggyList <DownloadRecord>(JsonStore); var item = dRecords.FirstOrDefault(x => x.Url == url); return(item); } }
public Reads() { var list1 = new BiggyList<Product>(); test1 = new Product { Sku = "XXX", Name = "Steve's Stuffs", Price = 100.00M }; list1.Add(test1); list1.Save(); //this should read from the file _products = new BiggyList<Product>(); }
public DataContext(string path) { Meetings = CreateList <Meeting>(path); MeetingSubjects = CreateList <MeetingSubject>(path); Users = CreateList <User>(path); MeetingTweetAlerts = CreateList <MeetingTweetAlert>(path); NewsletterLogs = CreateList <NewsletterLog>(path); NewsletterSubscriptions = CreateList <NewsletterSubscription>(path); }
public VehicleRepository(JsonStore<Vehicle> storage) { if (storage == null) { throw new ArgumentException("JsonStore"); } Storage = storage; AllItems = new BiggyList<Vehicle>(Storage); }
public SiteDB() { Links = new BiggyList<Link>(dbPath: HttpRuntime.AppDomainAppPath); ContactInfos = new BiggyList<ContactInfo>(dbPath: HttpRuntime.AppDomainAppPath); LogEntryList = new BiggyList<LogEntry>(dbPath: HttpRuntime.AppDomainAppPath); BlogLogEntryList = new BiggyList<LogEntry>(dbPath: HttpRuntime.AppDomainAppPath, dbName: "blogLog"); ArchiveLogList = new BiggyList<LogEntry>(dbPath: HttpRuntime.AppDomainAppPath, dbName: "archiveLog"); ErrorLogList = new BiggyList<ErrorLogItem>(dbPath: HttpRuntime.AppDomainAppPath, dbName: "errorLogList"); }
public void UpdateAlbums() { for (int i = 0; i < AlbumList.Count; i++) { var store = new BiggyList<Settings>(settingStore); Settings setting = new Settings(); setting.AlbumName = AlbumList[i]; store.Add(setting); } }
public SiteDB() { Links = new BiggyList <Link>(dbPath: HttpRuntime.AppDomainAppPath); ContactInfos = new BiggyList <ContactInfo>(dbPath: HttpRuntime.AppDomainAppPath); LogEntryList = new BiggyList <LogEntry>(dbPath: HttpRuntime.AppDomainAppPath); BlogLogEntryList = new BiggyList <LogEntry>(dbPath: HttpRuntime.AppDomainAppPath, dbName: "blogLog"); ArchiveLogList = new BiggyList <LogEntry>(dbPath: HttpRuntime.AppDomainAppPath, dbName: "archiveLog"); ErrorLogList = new BiggyList <ErrorLogItem>(dbPath: HttpRuntime.AppDomainAppPath, dbName: "errorLogList"); }
// Default constructor public Manager() { // Path to the app's read-write file system location var localData = HttpContext.Current.Server.MapPath("~/App_Data"); // Open (or create) the data store store = new JsonStore <PersonFull>(localData, "company", "persons"); // Assign (or create) the collection(s) persons = new BiggyList <PersonFull>(store); }
// Default constructor public Manager() { // Path to the app's read-write file system location var localData = HttpContext.Current.Server.MapPath("~/App_Data"); // Open (or create) the data store store = new JsonStore<PersonFull>(localData, "company", "persons"); // Assign (or create) the collection(s) persons = new BiggyList<PersonFull>(store); }
public void Adds_Item_To_List_And_Store() { // Just in case: _clients.Clear(); var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; _clients.Add(newClient); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList<Client>(_clientStore); Assert.True(altClientList.Count() > 0); }
//constructor public Manager() { //path var localData = HttpContext.Current.Server.MapPath("~/App_Data"); //Open or create data store store = new JsonStore <CarFull>(localData, "lab2", "cars"); //Assign collection cars = new BiggyList <CarFull>(store); }
public TenantScopedBiggyStoreCheckpointTracker(string tenantId, BiggyList <TenantCheckpointTokenDocument> tenantCheckpoints) { _tenantId = tenantId; _tenantCheckpoints = tenantCheckpoints; _nullTenantCheckpointTokenDocument = new TenantCheckpointTokenDocument { TenantId = _tenantId, CheckpointToken = NullCheckpointToken.Value }; }
public static void Run() { Console.WriteLine("Loading from File Store..."); var monkies = new BiggyList <Monkey>(); monkies.Clear(); var sw = new Stopwatch(); Console.WriteLine("Loading 10,000 documents"); sw.Start(); var addRange = new List <Monkey>(); for (int i = 0; i < 10000; i++) { monkies.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Loading 100,000 documents"); sw.Reset(); monkies.Clear(); sw.Start(); for (int i = 0; i < 100000; i++) { monkies.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count, sw.ElapsedMilliseconds); //use a DB that has an int PK sw.Reset(); sw.Start(); Console.WriteLine("Loading {0}...", monkies.Count); monkies.Reload(); sw.Stop(); Console.WriteLine("Loaded {0} documents from Postgres in {1}ms", monkies.Count, 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 BlogDB() { var app_data = HostingEnvironment.MapPath("~/App_Data/DB"); var dbCore = new JsonDbCore(app_data, "v2"); var pageStore = new JsonStore <Page>(dbCore); var postStore = new JsonStore <Post>(dbCore); Posts = new BiggyList <Post>(postStore); Pages = new BiggyList <Page>(pageStore); }
public void Biggylist_Adds_Single_Item_To_Json_Store() { var propertyList = new BiggyList<Property>(_propertyStore); int initialCount = propertyList.Count; var newProperty = new Property { Id = 1, Name = "Watergate Apartments", Address = "2639 I St NW, Washington, D.C. 20037" }; propertyList.Add(newProperty); // Reload from the store: propertyList = new BiggyList<Property>(_propertyStore); var addedItems = propertyList.FirstOrDefault(p => p.Name.Contains("Watergate")); Assert.IsTrue(initialCount == 0 && propertyList.Count == 1); }
public void Cancel(string url) { lock (JsonStore) { var dRecords = new BiggyList <DownloadRecord>(JsonStore); var item = dRecords.FirstOrDefault(x => x.Url == url); if (item != null) { item.IsCancelled = true; dRecords.Update(item); } } }
public void Biggylist_Adds_Single_Item_To_Sqlite_Store() { var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var newPropertyDocument = new PropertyDocument { Name = "Watergate Apartments", Address = "2639 I St NW, Washington, D.C. 20037" }; PropertyDocumentList.Add(newPropertyDocument); // Reload from the store: PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); var addedItems = PropertyDocumentList.FirstOrDefault(p => p.Name.Contains("Watergate")); Assert.IsTrue(initialCount == 0 && PropertyDocumentList.Count == 1 && addedItems.Id == 1); }
public Reads() { var list1 = new BiggyList <Product>(); test1 = new Product { Sku = "XXX", Name = "Steve's Stuffs", Price = 100.00M }; list1.Add(test1); list1.Save(); //this should read from the file _products = new BiggyList <Product>(); }
public Writes() { //clear out the list _products = new BiggyList<Product>(); //empty the db _products.ClearAndSave(); test1 = new Product { Sku = "XXX", Name = "Steve's Stuffs", Price = 100.00M }; _products.Saved += _products_Saved; _products.ItemAdded += _products_ItemAdded; _products.Add(test1); _products.Save(); }
public void Bulk_Inserts_Documents_With_String_PK() { int INSERT_QTY = 100; var addRange = new List<MonkeyDocument>(); for (int i = 0; i < INSERT_QTY; i++) { addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } IBiggyStore<MonkeyDocument> monkeyDocuments = new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName); var inserted = monkeyDocuments.Add(addRange); // Reload, make sure everything was persisted: var monkeys = new BiggyList<MonkeyDocument>(new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName)); Assert.True(monkeys.Count() == INSERT_QTY); }
public void Adds_Batch_Of_Items_To_Store() { _biggyWidgetList.Clear(); int INSERT_QTY = 100; var batch = new List<Widget>(); for (int i = 0; i < INSERT_QTY; i++) { batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M }); } _biggyWidgetList.Add(batch); // Reload the List: var itemsInStore = new BiggyList<Widget>(_widgets); Assert.True(itemsInStore.Count() == INSERT_QTY); }
public void Adds_Many_Items_To_List_And_Store() { int INSERT_QTY = 10; // Just in case: _clients.Clear(); var addThese = new List<Client>(); for (int i = 0; i < INSERT_QTY; i++) { var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" }; addThese.Add(newClient); } _clients.Add(addThese); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList<Client>(_clientStore); Assert.True(altClientList.Count() == INSERT_QTY); }
public static void Run() { Console.WriteLine("Loading from File Store..."); var clients = new BiggyList<Client>(new JsonStore<Client>("clients")); clients.Clear(); var sw = new Stopwatch(); // Write a modest-sized batch to a file: int SMALL_BATCH_QTY = 1000; Console.WriteLine("Write {0} documents", SMALL_BATCH_QTY); var addRange = new List<Client>(); for (int i = 0; i < SMALL_BATCH_QTY; i++) { addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clients.Add(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds); int LARGE_BATCH_QTY = 100000; Console.WriteLine("Write {0} documents", LARGE_BATCH_QTY); sw.Reset(); clients.Clear(); // Write a Bigger-sized batch to a file: // Reset the temp List; addRange = new List<Client>(); for (int i = 0; i < LARGE_BATCH_QTY; i++) { addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clients.Add(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); Console.WriteLine("Querying Middle 400 Documents"); var found = clients.Where(x => x.ClientId > 100 && x.ClientId < 500); sw.Stop(); Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds); }
public void Biggylist_Adds_Range_Of_Items_To_Pg_Store() { var propertyList = new BiggyList<Property>(_propertyStore); int initialCount = propertyList.Count; var myBatch = new List<Property>(); int qtyToAdd = 10; for (int i = 1; i <= qtyToAdd; i++) { var newProperty = new Property { Name = "New Apartment " + i, Address = "Some Street in a Lonely Town" }; myBatch.Add(newProperty); } propertyList.Add(myBatch); // Reload from the store: propertyList = new BiggyList<Property>(_propertyStore); var addedItems = propertyList.FirstOrDefault(p => p.Name.Contains("New Apartment")); Assert.IsTrue(initialCount == 0 && propertyList.Count == qtyToAdd); }
public void Biggylist_Adds_Range_Of_Items_To_Sqlite_Store() { var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); int initialCount = PropertyDocumentList.Count; var myBatch = new List<PropertyDocument>(); int qtyToAdd = 10; for (int i = 1; i <= qtyToAdd; i++) { var newPropertyDocument = new PropertyDocument { Name = "New Apartment " + i, Address = "Some Street in a Lonely Town" }; myBatch.Add(newPropertyDocument); } PropertyDocumentList.Add(myBatch); // Reload from the store: PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore); var addedItems = PropertyDocumentList.Where(p => p.Id > 0); Assert.IsTrue(initialCount == 0 && addedItems.Count() > 0); }
public static void Run() { Console.WriteLine("Loading from File Store..."); var monkies = new BiggyList<Monkey>(); monkies.Clear(); var sw = new Stopwatch(); Console.WriteLine("Loading 10,000 documents"); sw.Start(); var addRange = new List<Monkey>(); for (int i = 0; i < 10000; i++) { monkies.Add(new Monkey {ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Loading 100,000 documents"); sw.Reset(); monkies.Clear(); sw.Start(); for (int i = 0; i < 100000; i++) { monkies.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count, sw.ElapsedMilliseconds); //use a DB that has an int PK sw.Reset(); sw.Start(); Console.WriteLine("Loading {0}...", monkies.Count); monkies.Reload(); sw.Stop(); Console.WriteLine("Loaded {0} documents from Postgres in {1}ms", monkies.Count, 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 Biggylist_Adds_Range_Of_Items_To_Json_Store() { var propertyList = new BiggyList<Property>(_propertyStore); int initialCount = propertyList.Count; var myBatch = new List<Property>(); int qtyToAdd = 10; // This test uses an initial index value of 1 so taht there is a non-zero ID for the first item: for (int i = 1; i <= qtyToAdd; i++) { var newProperty = new Property { Id = i, Name = "New Apartment " + i, Address = "Some Street in a Lonely Town" }; myBatch.Add(newProperty); } propertyList.Add(myBatch); // Reload from the store: propertyList = new BiggyList<Property>(_propertyStore); var addedItems = propertyList.FirstOrDefault(p => p.Name.Contains("New Apartment")); Assert.IsTrue(initialCount == 0 && propertyList.Count == qtyToAdd); }
public static void Run() { var sw = new Stopwatch(); var _myDatabase = new PGCache("chinookPG"); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGRES DOCUMENTS - INSERT A BUNCH OF DOCUMENTS"); Console.WriteLine("==========================================================="); // Build a table to play with from scratch each time: if(_myDatabase.TableExists("ClientDocuments")) { _myDatabase.DropTable("\"ClientDocuments\""); } IBiggyStore<ClientDocument> clientDocStore = new PGDocumentStore<ClientDocument>(_myDatabase); IBiggy<ClientDocument> clientDocs = new BiggyList<ClientDocument>(clientDocStore); int INSERT_MODEST_QTY = 10000; Console.WriteLine("Insert {0} records as documents...", INSERT_MODEST_QTY); var addThese = new List<ClientDocument>(); for(int i = 0; i < INSERT_MODEST_QTY; i++) { addThese.Add(new ClientDocument { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clientDocs.Add(addThese); sw.Stop(); Console.WriteLine("Inserted {0} records as documents in {1} ms", INSERT_MODEST_QTY, sw.ElapsedMilliseconds); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGRES DOCUMENTS - SOME FANCY COMPLEX DOCUMENT STUFF"); Console.WriteLine("==========================================================="); // Start clean with no existing table: if (_myDatabase.TableExists("ArtistWithAlbums")) { _myDatabase.DropTable("\"ArtistWithAlbums\""); } Console.WriteLine("Retreive artists, albums, and tracks from Db..."); sw.Reset(); sw.Start(); IBiggyStore<Artist> _artistStore = new PGStore<Artist>(_myDatabase); IBiggyStore<Album> _albumStore = new PGStore<Album>(_myDatabase); IBiggyStore<Track> _trackStore = new PGStore<Track>(_myDatabase); IBiggy<Artist> _artists = new BiggyList<Artist>(_artistStore); IBiggy<Album> _albums = new BiggyList<Album>(_albumStore); IBiggy<Track> _tracks = new BiggyList<Track>(_trackStore); sw.Stop(); Console.WriteLine("Query each artists albums and write to complex document store..."); var list = new List<ArtistWithAlbums>(); foreach (var artist in _artists) { var artistAlbums = from a in _albums where a.ArtistId == artist.ArtistId select a; var newArtistWithAlbums = new ArtistWithAlbums() { ArtistId = artist.ArtistId, Name = artist.Name, Albums = artistAlbums.ToList() }; list.Add(newArtistWithAlbums); } var docStore = new PGDocumentStore<ArtistWithAlbums>(_myDatabase); var artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore); artistWithAlbumsDocuments.Add(list); sw.Stop(); Console.WriteLine("Added {0} Artist + Album records as complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Retreive artists and albums from Complex document store and hydrate"); sw.Reset(); sw.Start(); artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore); sw.Stop(); int artistCount = artistWithAlbumsDocuments.Count(); int albumsCount = 0; foreach (var artist in artistWithAlbumsDocuments) { albumsCount += artist.Albums.Count(); } Console.WriteLine("\tRetreived and Re-Hydrated {0} Artist + {1} Album records from complex documents in {2} ms", artistCount, albumsCount, sw.ElapsedMilliseconds); }
public void Updates_Item_With_OVerride_From_List_And_Store() { // Just in case: var overriddenClients = new BiggyList<Client>(new SQLServerStore<Client>(_hostDb)); overriddenClients.Clear(); // Add a new record: var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; overriddenClients.Add(newClient); int newId = newClient.ClientId; // Update the same record-by-id with a new instance. OverrideClient overrides Equals with the id: var updateMe = new Client() { ClientId = newId, LastName = "Appleseed", FirstName = "John", Email = "*****@*****.**" }; overriddenClients.Update(updateMe); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList<Client>(new SQLServerStore<Client>(_connectionStringName)); var updated = altClientList.FirstOrDefault(c => c.LastName == "Appleseed"); Assert.True(updated != null && updated.LastName == "Appleseed"); }
public void Updates_Item_From_List_And_Store() { // Just in case: _clients.Clear(); var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; _clients.Add(newClient); _clients = new BiggyList<Client>(_clientStore); var updateMe = _clients.FirstOrDefault(); updateMe.LastName = "Appleseed"; _clients.Update(updateMe); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList<Client>(new SQLServerStore<Client>(_connectionStringName)); var updated = altClientList.FirstOrDefault(c => c.LastName == "Appleseed"); Assert.True(updated != null && updated.LastName == "Appleseed"); }
public void Removes_Many_Items_From_List_And_Store() { int INSERT_QTY = 10; // Just in case: _clients.Clear(); var addThese = new List<Client>(); for (int i = 0; i < INSERT_QTY; i++) { var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" }; addThese.Add(newClient); } _clients.Add(addThese); // Open a new instance, to see if the item was added to the backing store as well: var altClientArray = new BiggyList<Client>(_clientStore).ToArray(); var removeThese = new List<Client>(); for (int i = 0; i < 5; i++) { removeThese.Add(altClientArray[i]); } _clients.Remove(removeThese); // Reload the list: _clients = new BiggyList<Client>(_clientStore); Assert.True(_clients.Count() == (INSERT_QTY - removeThese.Count())); }
public void Removes_Item_From_List_And_Store() { // Just in case: _clients.Clear(); var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; _clients.Add(newClient); int firstCount = _clients.Count(); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList<Client>(_clientStore); var deleteMe = altClientList.FirstOrDefault(); altClientList.Remove(deleteMe); Assert.True(firstCount > 0 && altClientList.Count() == 0); }
public void Biggylist_Updates_Range_Of_Items_In_Json_Store() { var propertyList = new BiggyList<Property>(_propertyStore); int initialCount = propertyList.Count; var myBatch = new List<Property>(); int qtyToAdd = 10; // This test uses an initial index value of 1 so taht there is a non-zero ID for the first item: for (int i = 1; i <= qtyToAdd; i++) { myBatch.Add(new Property { Id = i, Name = "John's Luxury Townhomes" + i, Address = i + " Property Parkway, Portland, OR 97204" }); } propertyList.Add(myBatch); // Just to be sure, reload from backing store and check what was added: propertyList = new BiggyList<Property>(_propertyStore); int addedCount = propertyList.Count; // Update each item: for (int i = 0; i < qtyToAdd; i++) { propertyList.ElementAt(i).Name = "John's Low-Rent Brick Homes " + i; } propertyList.Update(propertyList.ToList()); // Reload, and check updated names: propertyList = new BiggyList<Property>(_propertyStore); var updatedItems = propertyList.Where(p => p.Name.Contains("Low-Rent Brick")); Assert.IsTrue(updatedItems.Count() == qtyToAdd); }
public void Dispose() { CurrentList.Clear(); CurrentList = null; }