private void AssertExtentSize(int expectedCount, Type extent, IEmbeddedObjectContainer
			 db)
		{
			IQuery query = db.Query();
			query.Constrain(db.Ext().Reflector().ForName(extent.FullName));
			IObjectSet result = query.Execute();
			Assert.AreEqual(expectedCount, result.Count);
		}
Пример #2
0
        public void Update(IEntity entity)
        {
            var uuid = _container.Ext().GetID(entity);

            if (uuid <= 0)
            {
                var extEntity = entity;
                entity = _container.AsQueryable <IEntity>().FirstOrDefault(e => e.Id == extEntity.Id);
                if (entity == null)
                {
                    throw new NovaromaException(string.Format(Resources.EntityNotFoundInDb, extEntity.Id));
                }
                entity.CopyFrom(extEntity);
            }

            entity.IsModified = false;
            _container.Store(entity);
        }
Пример #3
0
 private static IObjectContainer OpenDb()
 {
     if (_Db == null)
     {
         string path = App.CombinePath("Db.yap");
         _Db = Db4oEmbedded.OpenFile(path);
     }
     return(_Db.Ext().OpenSession());
 }
Пример #4
0
        private void AssertExtentSize(int expectedCount, Type extent, IEmbeddedObjectContainer
                                      db)
        {
            IQuery query = db.Query();

            query.Constrain(db.Ext().Reflector().ForName(extent.FullName));
            IObjectSet result = query.Execute();

            Assert.AreEqual(expectedCount, result.Count);
        }
        private long StoreItemAndGetCommitTimestamp(IEmbeddedConfiguration config)
        {
            IEmbeddedObjectContainer db = OpenContainer(config);

            CommitTimestampDefragmentTestCase.Item item = new CommitTimestampDefragmentTestCase.Item
                                                              ();
            db.Store(item);
            db.Commit();
            long commitTimestamp = db.Ext().GetObjectInfo(item).GetCommitTimestamp();

            db.Close();
            return(commitTimestamp);
        }
        private void AssertVersionAfterDefrag(long version, IEmbeddedConfiguration afterDefragConfig
                                              )
        {
            IEmbeddedObjectContainer db = OpenContainer(afterDefragConfig);

            CommitTimestampDefragmentTestCase.Item retrievedItem = ((CommitTimestampDefragmentTestCase.Item
                                                                     )db.Query(typeof(CommitTimestampDefragmentTestCase.Item)).Next());
            long retrievedVersion = db.Ext().GetObjectInfo(retrievedItem).GetCommitTimestamp(
                );

            Assert.AreEqual(version, retrievedVersion);
            db.Close();
        }
        public override void Init(int flowCount, long flowRecordCount)
        {
            sessions = new IObjectContainer[flowCount];
            fileName = Path.Combine(DataDirectory, CollectionName + ".db4objects");

            IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();

            config.Common.ObjectClass(typeof(long)).ObjectField("Key").Indexed(true);
            database = Db4oEmbedded.OpenFile(config, fileName);

            for (int i = 0; i < flowCount; i++)
            {
                IObjectContainer obj = database.Ext().OpenSession();
                sessions[i] = obj;
            }
        }
Пример #8
0
 public virtual IObjectContainer OpenClient()
 {
     return(_server.Ext().OpenSession());
 }
Пример #9
0
        public NovaromaDb4OContext(IEmbeddedObjectContainer container)
        {
            container.Ext().Configure().OptimizeNativeQueries(true);

            container.Ext().Configure().ObjectClass(typeof(EntityBase)).ObjectField("_id").Indexed(true);

            container.Ext().Configure().ObjectClass(typeof(Media)).ObjectField("_title").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Media)).ObjectField("_year").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Media)).ObjectField("_rating").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Media)).ObjectField("_directory").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Media)).ObjectField("_imdbId").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Media)).ObjectField("_voteCount").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Media)).ObjectField("_runtime").Indexed(true);

            container.Ext().Configure().ObjectClass(typeof(Movie)).ObjectField("_filePath").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Movie)).ObjectField("_isWatched").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Movie)).ObjectField("_subtitleDownloaded").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Movie)).ObjectField("_notFound").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Movie)).ObjectField("_subtitleNotFound").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(Movie)).ObjectField("_downloadKey").Indexed(true);

            container.Ext().Configure().ObjectClass(typeof(TvShowEpisode)).ObjectField("_filePath").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(TvShowEpisode)).ObjectField("_isWatched").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(TvShowEpisode)).ObjectField("_subtitleDownloaded").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(TvShowEpisode)).ObjectField("_notFound").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(TvShowEpisode)).ObjectField("_subtitleNotFound").Indexed(true);
            container.Ext().Configure().ObjectClass(typeof(TvShowEpisode)).ObjectField("_downloadKey").Indexed(true);

            container.Ext().Configure().ObjectClass(typeof(TvShow)).CascadeOnDelete(true);
            container.Ext().Configure().ObjectClass(typeof(TvShowSeason)).CascadeOnDelete(true);

            container.Ext().Configure().MarkTransient("System.NonSerialized");
            container.Ext().Configure().UpdateDepth(5);
            container.Ext().Configure().CallConstructors(true);

            _container = container;
        }