예제 #1
0
        private void MakeDatabase()
        {
            Console.WriteLine("Creating Sample Db...");
            _path = Path.GetTempFileName();
            Configure(true);

            com.db4o.ObjectContainer db = com.db4o.Db4oFactory.OpenFile(_path);
            ((com.db4o.YapStream)db).GetNativeQueryHandler().QueryOptimizationFailure += new com.db4o.inside.query.QueryOptimizationFailureHandler(OnQueryOptimizationFailure);


            for (int i = 0; i < 10000; i++)
            {
                Entry e = new Entry();
                e._name             = new MultiText();
                e._name._singleForm = new LanguageForm("en", i.ToString());
                e._name._forms[0]   = new LanguageForm("en", i.ToString());
                db.Set(e);
            }

            //http://tracker.db4o.com/jira/browse/COR-279 makes me worried about indexes not
            //being used until the db is reopened, maybe?

            db.Commit();
            db.Close();
            db.Dispose();
        }
예제 #2
0
        /// <summary>
        /// Cause Db4o to do one-time overhead stuff, chiefly loading
        /// the dll for evaluating native queries.
        /// </summary>
        public void PrimeTheQueryPump()
        {
            Console.WriteLine("PrimeTheQueryPump...");
            string path = Path.GetTempFileName();

            com.db4o.ObjectContainer db = com.db4o.Db4oFactory.OpenFile(path);
            db.Set(new LanguageForm("en", "hello"));
            db.Commit();
            //SODA doesn't prime it: db.Query().Execute();
            db.Query <LanguageForm>(
                delegate(LanguageForm x)
            {
                return(true);
            });

            db.Close();
            db.Dispose();
            File.Delete(path);
        }