示例#1
0
 public ThingRepository(string collectionName, IConfiguration config, IDateContext dateContext, IUserContext userContext)
     : base(collectionName, config, dateContext, userContext)
 {
     //
     Collection.Indexes.CreateOne(
         Builders <Thing> .IndexKeys.Ascending(cp => cp.Name), new CreateIndexOptions
     {
         Name   = "name_u",
         Unique = true
     });
 }
示例#2
0
        public MongoRepository(
            string collectionName,
            IConfiguration config,
            IDateContext dateContext,
            IUserContext userContext)
        {
            _dateContext = dateContext;
            _userContext = userContext;
            var url = MongoUrl.Create(config.Get <string>("Data:App:ConnectionString"));

            Database   = new MongoClient(url).GetDatabase(url.DatabaseName);
            Collection = Database.GetCollection <T>(collectionName);

            // Version index for quickly determining the latest version
            Collection.Indexes.CreateOne(Builders <T> .IndexKeys.Descending(t => t.Version));
            Collection.Indexes.CreateOne(Builders <T> .IndexKeys.Ascending(t => t.Created));
            Collection.Indexes.CreateOne(Builders <T> .IndexKeys.Ascending(t => t.CreatedBy));
            Collection.Indexes.CreateOne(Builders <T> .IndexKeys.Descending(t => t.CreatedBy));
            Collection.Indexes.CreateOne(Builders <T> .IndexKeys.Ascending(t => t.Updated));
            Collection.Indexes.CreateOne(Builders <T> .IndexKeys.Ascending(t => t.UpdatedBy));
            Collection.Indexes.CreateOne(Builders <T> .IndexKeys.Descending(t => t.UpdatedBy));
        }
示例#3
0
 public ThingRepository(IConfiguration config, IDateContext dateContext, IUserContext userContext)
     : base(config, dateContext, userContext)
 {
 }
示例#4
0
 public MongoRepository(
     IConfiguration config,
     IDateContext dateContext,
     IUserContext userContext) : this(typeof(T).Name, config, dateContext, userContext)
 {
 }
示例#5
0
 public StatusRepository(string collectionName, IConfiguration config, IDateContext dateContext, IUserContext userContext)
     : base(collectionName, config, dateContext, userContext)
 {
     Init();
 }
示例#6
0
 public StatusRepository(IConfiguration config, IDateContext dateContext, IUserContext userContext)
     : base(config, dateContext, userContext)
 {
     Init();
 }