Beispiel #1
0
        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();
                            }
                        }
                    }
                }
        }
Beispiel #2
0
 public DemoDictionary(string folder)
 {
     EsentDatabase.Settings settings = new EsentDatabase.Settings()
     {
         folderLocation = folder,
         folderName     = null,
     };
     sessionPool = EsentDatabase.open(settings, typeof(DictionaryEntry));
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
                }
        }
Beispiel #5
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = EsentDatabase.open(typeof(Person).GetTypeInfo().Assembly))
             using (var sess = db.GetSession())
             {
                 if (db.isNewDatabase)
                 {
                     Person.populateWithDebugData(sess);
                     FiltersTest.populateWithDebugData(sess);
                 }
                 testPersons(sess);
                 // testFilters( sess );
             }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Failed: {0}", ex.Message);
     }
 }
Beispiel #6
0
        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.");
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            using (var pool = EsentDatabase.open(typeof(Record)))
            {
                while (true)
                {
                    Console.WriteLine("c = create, r = read, u = update, d = delete, s = search, a = all, q = quit");
                    char c = char.ToLower(Console.ReadKey().KeyChar);
                    Console.WriteLine();
                    if ('q' == c)
                    {
                        return;
                    }

                    tAction act;
                    if (!actions.TryGetValue(c, out act))
                    {
                        continue;
                    }

                    using (var sess = pool.GetSession())
                        using (var trans = sess.BeginTransaction())
                        {
                            try
                            {
                                if (act(sess))
                                {
                                    trans.Commit();
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Error: {0}", ex.Message);
                            }
                        }
                }
            }
        }
Beispiel #8
0
        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));
            }
        }