Ejemplo n.º 1
0
 public override IEntityContextConfiguration GetConfiguration()
 {
     var entityContextConfiguration = new EntityContextConfiguration();
     var connection = new EntityContextConnection(ConnectionString, Database);
     entityContextConfiguration.Connection = connection;
     return entityContextConfiguration;
 }
Ejemplo n.º 2
0
        public EntityContext(EntityContextConnection connection)
        {
            _connection     = connection;
            _collectionName = typeof(T).Name;
            if (!_connection.Database.CollectionExists(_collectionName))
            {
                _connection.Database.CreateCollection(_collectionName);
            }

            _collection = _connection.Database.GetCollection <T>(_collectionName);
        }
 public static IConfigure UsingMongoDb(this IConfigure configure, string connectionString, string databaseName)
 {
     var entityContextConfiguration = new EntityContextConfiguration();
     var connection = new EntityContextConnection(connectionString, databaseName);
     entityContextConfiguration.Connection = connection;
     configure.Container.Bind<IEntityContextConfiguration>(entityContextConfiguration);
     configure.Container.Bind((EntityContextConnection)entityContextConfiguration.Connection);
     configure.Container.Bind(typeof(IEntityContext<>), typeof(EntityContext<>));
     configure.Commands.Storage = entityContextConfiguration;
     return configure;
 }
Ejemplo n.º 4
0
        public static IConfigure UsingMongoDB(this IHaveStorage storage, Action<EntityContextConfiguration> configureCallback)
        {
            var entityContextConfiguration = new EntityContextConfiguration();
            configureCallback(entityContextConfiguration);

            var connection = new EntityContextConnection(entityContextConfiguration);
            entityContextConfiguration.Connection = connection;

            storage.EntityContextConfiguration = entityContextConfiguration;
            return Configure.Instance;
        }