public LiteDbContext(ILiteDatabase liteDatabase) { _database = liteDatabase ?? throw new ArgumentNullException(nameof(liteDatabase)); Applications = new LiteDbCollection <Application>(_database); Applications.EnsureIndex(x => x.HierarchyPath); }
public MongoDbService(MongoDBConfig dBConfig) { _dBConfig = dBConfig; _client = new MongoClient(new MongoClientSettings() { Server = MongoServerAddress.Parse(_dBConfig.Host), Credential = string.IsNullOrEmpty(_dBConfig.AuthMechanism) ? null : MongoCredential.CreateCredential( _dBConfig.AuthSource, _dBConfig.Username, _dBConfig.Password ) }); _dB = _client.GetDatabase(_dBConfig.Database); _data = _dB.GetCollection <CcData>(_dBConfig.CollectionData); _events = _dB.GetCollection <CcEvent>(_dBConfig.CollectionEvents); _groups = _dB.GetCollection <CcGroup>(_dBConfig.CollectionGroups); Data = new MongoCollection <CcData>(_data); Events = new MongoCollection <CcEvent>(_events); Groups = new MongoCollection <CcGroup>(_groups); }
//Scoped模式 public BaseService(IContext context) { this.context = context; this.repository = Repository <T> .Instance; this.collection = repository.GetCollection(); if (this.GetContext() != null && this.GetContext().IsUseCache) { cache = LocalCache <T> .Instance; RebuildCache(); } }
//Scoped模式 public BaseService(IContext context) { this.context = context; this.repository = Repository <T> .Instance; this.collection = repository.GetCollection(DatabaseManager.Instance.GetDbName(typeof(T))); if (this.GetContext().IsUseCache) { cache = LocalCache <T> .Instance; RebuildCache(); } }
public static async Task <long> MarkAsReadAsync(this IDbCollection <CcEvent> collection, IEnumerable <CcEvent> documents) { var i = 0L; foreach (var document in documents.Where(j => j.IsNew)) { document.IsNew = false; await collection.UpdateDocumentAsync(document); i++; } return(i); }
//Singleton模式 public BaseService(IContextRepository contextRepository) { this.contextRepository = contextRepository; this.repository = Repository <T> .Instance; this.collection = repository.GetCollection(); //if (this.GetContext() != null && this.GetContext().IsUseCache) //{ // cache = LocalCache<T>.Instance; // RebuildCache(); //} cache = LocalCache <T> .Instance; RebuildCache(); }
//Singleton模式 public BaseService(IContextRepository contextRepository) { this.contextRepository = contextRepository; this.repository = Repository <T> .Instance; this.collection = repository.GetCollection(DatabaseManager.Instance.GetDbName(typeof(T))); if (this.GetContext().IsUseCache) { cache = LocalCache <T> .Instance; RebuildCache(); } if (_historyService == null) { _historyService = new HistoryService(); } }
public AccountManager(IDbCollection dbCollection) { this.AccountCollection = dbCollection; }
public ModelsEntityRepository(ILoggerFactory logger, IDatabaseContext context) { _logger = logger.CreateLogger <ModelsEntityRepository>(); _models = context.GetCollection <ModelsEntity>(CollectionName); }
public UserRepository(ILoggerFactory logger, IDatabaseContext context) { _logger = logger.CreateLogger <UserRepository>(); _users = context.GetCollection <User>(CollectionName); }
private Repository() { db = DatabaseManager.Instance.GetDatabase(GetDbName(typeof(T).FullName)); collection = db.GetCollection <T>(); }
public BaseService() { this.contextRepository = null; this.repository = Repository <T> .Instance; this.collection = repository.GetCollection(DatabaseManager.Instance.GetDbName(typeof(T))); }
public TemplateEntityRepository(ILoggerFactory logger, IDatabaseContext context) { _logger = logger.CreateLogger <TemplateEntityRepository>(); _Templates = context.GetCollection <TemplateEntity>(CollectionName); }