Ejemplo n.º 1
0
        public RecordMongoRepository(IMongoRepositorySettings <RecordModel> settings)
        {
            MongoClient    client   = new MongoClient(settings.ConnectionString);
            IMongoDatabase database = client.GetDatabase(settings.DatabaseName);

            this.collection = database.GetCollection <RecordModel>(settings.CollectionName);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <remarks>Error codes follow the format DAL-DMB-1XX</remarks>
 /// <param name="repository">The IMongoDbRepository for the data store</param>
 /// <param name="auditSettings">Optional dictionary of audit settings</param>
 /// <param name="auditUser">Option string for the audit user</param>
 public DataManagerBase(IMongoRepositorySettings repositorySettings, Dictionary <string, string> auditSettings = null, string auditUser = null, string workingClientId = null)
 {
     Repository = new MongoDbRepository(repositorySettings);
     if (auditSettings != null)
     {
         AuditSettings = auditSettings;
     }
     if (!String.IsNullOrEmpty(auditUser))
     {
         AuditUser = auditUser;
     }
     if (!String.IsNullOrEmpty(workingClientId))
     {
         WorkingClientId = workingClientId;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructor for the class
        /// </summary>
        /// <param name="connectionString">The connection string to the data store</param>
        /// <param name="databaseName">The database name to target</param>
        public MongoDbRepository(IMongoRepositorySettings settings)
        {
            _IndexingDisabled = settings.IndexingDisabled;
            var clientSettings = MongoClientSettings.FromUrl(new MongoUrl(settings.ConnectionString));

            if (settings.Log)
            {
                clientSettings.ClusterConfigurator = cb =>
                {
                    cb.Subscribe <MongoDB.Driver.Core.Events.CommandStartedEvent>(e =>
                    {
                        System.Diagnostics.Debug.WriteLine($"{e.CommandName} - {e.Command.ToJson()}");
                    });
                };
            }
            _Client = new MongoClient(clientSettings);
            if (_Client != null)
            {
                _Database = _Client.GetDatabase(settings.DatabaseName);
            }
            //register conventions
            RegisteringConventionsPack(settings.ConventionsPackName);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="repositorySettings">The IMongoRepositorySettings settings for the manager</param>
 /// <param name="auditSettings">Optional audit settings to use</param>
 /// <param name="auditUser">Optional name of the user to save for audi</param>
 /// <param name="workingClientId">Optional id for the current client</param>
 public GenericDataManager(IMongoRepositorySettings repositorySettings, Dictionary <string, string> auditSettings = null, string auditUser = null, string workingClientId = null) : base(repositorySettings, auditSettings, auditUser, workingClientId)
 {
 }