private void button11_Click(object sender, EventArgs e) { DateTime now = DateTime.UtcNow; string table = "Task1"; Entity_Task entity = new Entity_Task() { Description = "Client 2 " + now.Ticks, Id = now.Ticks, SyncTimestamp = now.Ticks }; using (var tran = DBEngineClient2.GetTransaction()) { //tran.SynchronizeTables() - must be called when necessary also adding sync indexes table byte[] pBlob = null; //First inserting blob (entity content) pBlob = tran.InsertDataBlockWithFixedAddress <Entity_Task>(table, pBlob, entity); //Entity is stored in the same table //Then calling sync indexes also with the pointer to the entity content (row.Value in this case) EntitySyncingClient.SyncStrategyV1 <Entity_Task> .InsertIndex4Sync(tran, table, entity, pBlob, null); tran.Commit(); } }
/// <summary> /// Insert server /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { DateTime now = DateTime.UtcNow; string table = "TaskSyncUser1"; //Adding task using (var tran = DBEngine.GetTransaction()) { //tran.SynchronizeTables() - must be called when necessary also adding sync indexes table Entity_Task_Server entity = new Entity_Task_Server() { Description = "w1 " + now.Ticks, //Id = 1, Id = now.Ticks, SyncTimestamp = now.Ticks }; byte[] pBlob = null; pBlob = tran.InsertDataBlockWithFixedAddress <Entity_Task_Server>(table, pBlob, entity); //Entity is stored in the same table //must be called to insert synchro indexes EntitySyncing.SyncStrategyV1 <Entity_Task_Server> .InsertIndex4Sync(tran, table, entity, pBlob, null); tran.Commit(); } }
public void Run(string directory, string filter, double minSimilarity, Func<bool> continueTest) { var allfiles = System.IO.Directory.GetFiles(directory, filter, System.IO.SearchOption.AllDirectories); using (var engine = new DBreezeEngine(dbConf)) { allfiles.AsParallel().ForAll(f => { if (continueTest()) { using (var tran = engine.GetTransaction()) { GetHistogram(tran, f); tran.Commit(); } OnPrepareProgress(allfiles.Length); } }); var list = ((ushort)allfiles.Length).GetIndexCombinations(); var total = list.Count(); if (continueTest()) { list.AsParallel().ForAll(c => { if (!continueTest()) { return; } var f = allfiles[c[0]]; var l = allfiles[c[1]]; var value = 0.0; using (var tran = engine.GetTransaction()) { tran.ValuesLazyLoadingIsOn = false; value = GetComparisonResult(tran, f, l); tran.Commit(); } if (OnCompareProgress != null) { if (value >= minSimilarity) { OnCompareProgress(total, f, l, value); } else { OnCompareProgress(total, null, null, 0); } } }); } } }
public void CreateDbOnFsAndInsertAndSelectObject() { var conf = new DBreezeConfiguration { DBreezeDataFolderName = this.path, Storage = DBreezeConfiguration.eStorage.DISK }; using (var engine = new DBreezeEngine(conf)) using (var tran = engine.GetTransaction()) { var folder = new TestClass { Name = "Name" }; tran.Insert<int, DbCustomSerializer<TestClass>>("objects", 1, folder); tran.Commit(); Assert.AreEqual("Name", (tran.Select<int, DbCustomSerializer<TestClass>>("objects", 1).Value.Get as TestClass).Name); } }
private void UseValues(string databasePath, int key, int val) { using (var engine = new DBreeze.DBreezeEngine(databasePath)) { using (var transaction = engine.GetTransaction()) { //var row = transaction.Select<int, int>("t", key); transaction.Insert("t", key, val); transaction.Commit(); } } using (var engine = new DBreeze.DBreezeEngine(databasePath)) { using (var transaction = engine.GetTransaction()) { var row = transaction.Select<int, int>("t", key); if (!row.Exists) { Console.WriteLine("Stored value incorrect"); } } } }