static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); EsentDatabase.Settings settings = new EsentDatabase.Settings() { maxConcurrentSessions = 1, folderLocation = Environment.ExpandEnvironmentVariables(@"%APPDATA%\EsentDemoApp") }; using (var pool = EsentDatabase.open(settings, typeof(Program).Assembly)) using (var sess = pool.GetSession()) { if (pool.isNewDatabase) { Person.populateWithDebugData(sess); } using (var trans = sess.BeginTransaction()) { using (var frm = new Form1(sess)) { if (DialogResult.OK == frm.ShowDialog()) { trans.Commit(); } } } } }
public DemoDictionary(string folder) { EsentDatabase.Settings settings = new EsentDatabase.Settings() { folderLocation = folder, folderName = null, }; sessionPool = EsentDatabase.open(settings, typeof(DictionaryEntry)); }
static void Main(string[] args) { string strDatabasePath = Environment.ExpandEnvironmentVariables(@"%APPDATA%\EsentSchemaUpgradeDemo"); EsentDatabase.Settings settings = new EsentDatabase.Settings(strDatabasePath); using (var serializer = new EseSerializer(settings, 1, null)) using (var sess = serializer.OpenDatabase(false)) { if (serializer.isNewDatabase) { sess.AddType(typeof(Person)); PopulateDemoDatabase(sess); DatabaseSchemaUpdater dbUpdater = new DatabaseSchemaUpdater(sess); dbUpdater.DatabaseSchemaVersion = DB_SCHEMA_VERSION; dbUpdater.Execute(); } else { DatabaseSchemaUpdater dbUpdater = new DatabaseSchemaUpdater(sess); switch (dbUpdater.DatabaseSchemaVersion) { case 0: dbUpdater.DatabaseSchemaVersion = DB_SCHEMA_VERSION; goto case 1; case 1: dbUpdater.AddColumn <Person>("note"); dbUpdater.DatabaseSchemaVersion = 2; goto case 2; case 2: dbUpdater.CreateIndex <Person>("name"); dbUpdater.DatabaseSchemaVersion = 3; goto case 3; case DB_SCHEMA_VERSION: break; default: throw new ApplicationException("Unknown DB schema version #" + dbUpdater.DatabaseSchemaVersion.ToString()); } dbUpdater.Execute(); sess.AddType(typeof(Person)); } Console.WriteLine("Initialized OK"); } }
static void Main(string[] args) { if (1 != args.Length) { Console.WriteLine("Usage: RestoreDatabase.exe <backup-path>"); return; } string path = args [0]; EsentDatabase.Settings settings = new EsentDatabase.Settings() { maxConcurrentSessions = 1, folderLocation = Environment.ExpandEnvironmentVariables(@"%APPDATA%\EsentDemoApp") }; eKind kind; if (Directory.Exists(path)) { kind = eKind.Streaming; } else if (File.Exists(path)) { kind = eKind.External; } else { Console.WriteLine("The argument is neither file nor directory."); return; } try { switch (kind) { case eKind.External: Backup.ExternalRestore(new FileStream(path, FileMode.Open, FileAccess.Read), settings); break; case eKind.Streaming: Backup.StreamingRestore(path, settings); break; } } catch (Exception ex) { Console.WriteLine("Failed: {0}", ex.Message); } Console.WriteLine("Restored OK"); }
public DB() { // This demo app opens/closes the database with each test. // That's not normally done: usually, the database is initialized only once when application is launched. // To optimize for such unusual use case, we're tuning a few advanced DB parameters here. EsentDatabase.Settings settings = new EsentDatabase.Settings(); settings.advanced.EnableFileCache = true; // Use Windows file cache settings.advanced.EnableViewCache = true; // Read directly from the memory-mapped DB pool = EsentDatabase.open(settings, typeof(Record)); // Precompile query to filter records by that random column. qBetween = pool.filter((Record r, int from, int to) => r.randomInt >= from && r.randomInt <= to); }
static void Main(string[] args) { EsentDatabase.Settings settings = new EsentDatabase.Settings() { maxConcurrentSessions = 1, folderLocation = Environment.ExpandEnvironmentVariables(@"%APPDATA%\EsentDemoApp") }; using (var pool = EsentDatabase.open(settings, typeof(Program).Assembly)) using (var sess = pool.GetSession()) { if (pool.isNewDatabase) { Person.populateWithDebugData(sess); FiltersTest.populateWithDebugData(sess); } RunTests(sess); } }
static void Main(string[] args) { Console.WriteLine("Starting the service..."); EsentDatabase.Settings settings = new EsentDatabase.Settings() { maxConcurrentSessions = 16, folderLocation = Environment.ExpandEnvironmentVariables(@"%APPDATA%\EsentDemoApp") }; using (SessionPool pool = EsentDatabase.open(settings, typeof(Person))) { if (pool.isNewDatabase) { using (var sess = pool.GetSession()) PopulateDemoDatabase(sess); } Service singletoneInstance = new Service(pool); using (ServiceHost host = new ServiceHost(singletoneInstance, ServiceConfig.baseAddress)) { host.AddServiceEndpoint(typeof(iPersonsService), new NetNamedPipeBinding(), ServiceConfig.pipeName); host.Open(); ServiceConfig.eventServerReady.Set(); try { Console.WriteLine("Server running. Press any key to shut down"); Console.ReadKey(true); Console.WriteLine("Shutting down..."); } finally { ServiceConfig.eventServerReady.Reset(); } } } Console.WriteLine("The service has stopped."); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); EsentDatabase.Settings settings = new EsentDatabase.Settings(Environment.ExpandEnvironmentVariables(@"%APPDATA%\EseFileSystemDemo")); settings.PresetMedium(); using (var sp = EsentDatabase.open(settings, typeof(EseFileSystem.EfsEntry))) { if (sp.isNewDatabase) { using (var sess = sp.GetSession()) using (var trans = sess.BeginTransaction()) { var cur = sess.Cursor <EseFileSystem.EfsEntry>(); cur.Add(EseFileSystem.EfsEntry.NewRoot()); trans.Commit(); } } Application.Run(new Form1(sp)); } }