public string ToQuery() { var executionModel = InternalProvider.UnderlyingQueryable.GetExecutionModel(); var entityMapper = new EntityMapper <TEntity>(); return($"db.{entityMapper.GetCollectionName()}.{executionModel}"); }
/// <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); }
public void CollectionNameAndSchemaFromAttribute() { var mapper = new EntityMapper <CustomCollectionAndSchemaModel>(); Assert.AreEqual("CustomSchema.CustomCollection", mapper.GetCollectionName()); }
public void CollectionNameFromClassName() { var mapper = new EntityMapper <DefaultCollectionNameModel>(); Assert.AreEqual("DefaultCollectionNameModel", mapper.GetCollectionName()); }