コード例 #1
0
        public string ToQuery()
        {
            var executionModel = InternalProvider.UnderlyingQueryable.GetExecutionModel();
            var entityMapper   = new EntityMapper <TEntity>();

            return($"db.{entityMapper.GetCollectionName()}.{executionModel}");
        }
コード例 #2
0
        /// <summary>
        /// Initialise a new entity reader and writer to the specified database.
        /// </summary>
        /// <param name="database"></param>
        public void SetDatabase(IMongoDatabase database)
        {
            Database = database;

            var entityMapper = new EntityMapper <TEntity>();

            EntityWriter = new DbEntityWriter <TEntity>(database, entityMapper);
            EntityReader = new DbEntityReader <TEntity>(database, entityMapper);

            //TODO: Look at this again in the future, this seems unnecessarily complex
            var indexMapper = new EntityIndexMapper <TEntity>(entityMapper);
            var collection  = database.GetCollection <TEntity>(entityMapper.GetCollectionName());

            EntityIndexWriter = new EntityIndexWriter <TEntity>(collection, indexMapper);

            EntityRelationshipWriter = new EntityRelationshipWriter <TEntity>(database, entityMapper);
        }
コード例 #3
0
        public void CollectionNameAndSchemaFromAttribute()
        {
            var mapper = new EntityMapper <CustomCollectionAndSchemaModel>();

            Assert.AreEqual("CustomSchema.CustomCollection", mapper.GetCollectionName());
        }
コード例 #4
0
        public void CollectionNameFromClassName()
        {
            var mapper = new EntityMapper <DefaultCollectionNameModel>();

            Assert.AreEqual("DefaultCollectionNameModel", mapper.GetCollectionName());
        }