public void SaveEntities <TEntity>(IEnumerable <TEntity> entities) { using (LiteDatabase db = new LiteDatabase(_appSettings.LightDbConnection)) { ILiteCollection <TEntity> col = db.GetCollection <TEntity>(typeof(TEntity).Name); col.Upsert(entities); } }
public List <TEntity> GetEntities <TEntity>() { using (LiteDatabase db = new LiteDatabase(_appSettings.LightDbConnection)) { ILiteCollection <TEntity> col = db.GetCollection <TEntity>(typeof(TEntity).Name); return(col.Query().ToList()); } }
public LiteDbCollection(ILiteDatabase database) { if (database == null) { throw new ArgumentNullException(nameof(database)); } _collection = database.GetCollection <TEntity>(typeof(TEntity).Name); }
public ScheduledEvent[] FindGuildEvents( ulong guildId, string message = null, EventState? state = null, int limit = 0) { ILiteCollection<ScheduledEvent> collection = EnsureEventCollection(guildId); return FindInternal(collection, message, state, limit); }
public void GlobalCleanupNormal() { _fileMetaNormalCollection = null; _databaseInstanceNormal?.Checkpoint(); _databaseInstanceNormal?.Dispose(); _databaseInstanceNormal = null; File.Delete(DatabasePath); }
public RelationshipRepositoryTest() { this.liteDb = new LiteRepository(new MemoryStream()); this.eventSource = this.mocks.Create <IChangedMessageBus <IRelationship> >(); this.entityRepository = new EntityRepository(this.liteDb, this.mocks.Create <IChangedMessageBus <IEntity> >(MockBehavior.Loose).Object); this.tagRepository = new TagRepository(this.liteDb, this.mocks.Create <IChangedMessageBus <ITag> >(MockBehavior.Loose).Object); this.categoryRepository = new CategoryRepository(this.liteDb); this.relationshipRepository = new RelationshipRepository(this.liteDb, this.eventSource.Object); this.relationships = this.liteDb.Database.GetCollection("relationships"); }
/// <summary> /// Initializes a new instance of the <see cref="LiteDbStockRepository"/> class. /// </summary> /// <param name="db">Lite database.</param> public LiteDbStockRepository(LiteDatabase db) { if (db == null) { throw new NoNullAllowedException(); } this.stocks = db.GetCollection <Stock>("Stock"); this.stocks.EnsureIndex(s => s.Symbol, unique: true); }
/// <summary> /// Index Question /// </summary> /// <param name="QuestionCollection">Question Collection</param> private void IndexQuestion(ILiteCollection <Question> QuestionCollection) { // Index on QuestionId QuestionCollection.EnsureIndex(x => x.QuestionId); // Index on QuestionNumber // QuestionCollection.EnsureIndex(x => x.QuestionNumber); }
protected virtual ILiteCollection <T> GetCollection(bool refresh = false) { if (this.collection == null || refresh) { this.collection = this.GetDatabase(refresh).GetCollection <T>(); OnCollectionCreated(this.collection); OnCollectionCreated(); } return(this.collection); }
/// <summary> /// パッケージ情報を更新します。 /// </summary> /// <param name="new_pkginfo">新しいパッケージ情報</param> /// <returns></returns> public bool UpdatePackageInfo(PackageInfo new_pkginfo) { using (LiteDatabase db = new LiteDatabase(@"./database/packages.db")) { ILiteCollection <PackageInfo> pkginfo_col = db.GetCollection <PackageInfo>("package_info"); pkginfo_col.Update(new_pkginfo); } return(true); }
/// <summary> /// 新しいパッケージ情報を登録します。 /// </summary> /// <param name="package_info">新しいパッケージ情報</param> /// <returns></returns> public bool RegisterPackageInfo(PackageInfo package_info) { using (LiteDatabase db = new LiteDatabase(@"./database/packages.db")) { ILiteCollection <PackageInfo> pkginfo_col = db.GetCollection <PackageInfo>("package_info"); pkginfo_col.Insert(package_info); } return(true); }
public void GlobalSetupCompoundIndexVariant() { DatabaseInstance = new LiteDatabase(ConnectionString()); _fileMetaCollection = DatabaseInstance.GetCollection <FileMetaBase>(); _fileMetaCollection.EnsureIndex(COMPOUND_INDEX_NAME, $"$.{nameof(FileMetaBase.IsFavorite)};$.{nameof(FileMetaBase.ShouldBeShown)}"); _fileMetaCollection.Insert(FileMetaGenerator <FileMetaBase> .GenerateList(DatasetSize)); // executed once per each N value DatabaseInstance.Checkpoint(); }
public void GlobalIgnorePropertySetup() { File.Delete(DatabasePath); DatabaseInstance = new LiteDatabase(ConnectionString()); _fileMetaExclusionCollection = DatabaseInstance.GetCollection <FileMetaWithExclusion>(); _fileMetaExclusionCollection.EnsureIndex(fileMeta => fileMeta.ShouldBeShown); _baseDataWithBsonIgnore = FileMetaGenerator <FileMetaWithExclusion> .GenerateList(DatasetSize); // executed once per each N value }
public void GlobalSetup() { File.Delete(DatabasePath); DatabaseInstance = new LiteDatabase(ConnectionString()); _fileMetaCollection = DatabaseInstance.GetCollection <FileMetaBase>(); _fileMetaCollection.Insert(FileMetaGenerator <FileMetaBase> .GenerateList(DatasetSize)); // executed once per each N value DatabaseInstance.Checkpoint(); }
private MessageBoxContext() { var folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Shard"); Directory.CreateDirectory(folder); db = new LiteDatabase(Path.Combine(folder, "tracking.db")); messages = db.GetCollection <TrackedMessage>("trackedMessages"); logs = db.GetCollection <LogEntry>("logEntries"); storage = db.GetStorage <Guid>(); }
public DatabaseService(ConfigService configService) { this.configService = configService; db = new LiteDatabase(this.configService.GetAppPath("data.db")); // Get customer collection this.PermissionCollection = db.GetCollection <Permission>("Permission"); this.AppPermissionCollection = db.GetCollection <AppPermission>("AppPermission"); this.SettingsCollection = db.GetCollection <Settings>("Settings"); }
public static Account GetAccount(string accountId, bool showTransaction = false) { ILiteCollection <Account> accounts = DataContext.accounts; if (showTransaction) { accounts.Include(x => x.Transactions); } return(accounts.FindById(accountId)); }
public void Deactivate() { SisbaseBot.Instance.Client.MessageReactionRemoved -= ReactionRemoved; SisbaseBot.Instance.Client.MessageReactionAdded -= ReactionAdded; Database.Dispose(); categoryCache = null; Name = null; Status = false; Timeout = TimeSpan.Zero; }
public GroupBy_Tests() { local = DataGen.Person(1, 1000).ToArray(); db = new LiteDatabase(new MemoryStream()); collection = db.GetCollection <Person>(); collection.Insert(local); collection.EnsureIndex(x => x.Age); }
public SeriesDb() { if (!Debugger.IsAttached) { Directory.CreateDirectory(Path.Combine(PATH, APP_NAME)); } db = new LiteDatabase(Debugger.IsAttached ? FILE : Path.Combine(PATH, APP_NAME, FILE)); collection = db.GetCollection <Series>(COLL_SERIES); collection.EnsureIndex(c => c.Name); }
public AnnoStorage() { if (db == null) { db = AnnoDataBase.Db; col = db.GetCollection <AnnoData>(); col.EnsureIndex(x => x.Id); col.EnsureIndex(x => x.App); } }
public TimingWriter(IMetaDatabaseHandler databaseHandler) { _spawnCollection = databaseHandler.GetCollection <RunMeta <int> >("MetaSpawnTiming"); _netherCollection = databaseHandler.GetCollection <RunMeta <int> >("MetaNetherTiming"); _fortressCollection = databaseHandler.GetCollection <RunMeta <int> >("MetaFortressTiming"); _blazeCollection = databaseHandler.GetCollection <RunMeta <int> >("MetaBlazeTiming"); _searchCollection = databaseHandler.GetCollection <RunMeta <int> >("MetaSearchTiming"); _strongholdCollection = databaseHandler.GetCollection <RunMeta <int> >("MetaStrongholdTiming"); _endCollection = databaseHandler.GetCollection <RunMeta <int> >("MetaEndTiming"); }
public LayerService(IEnumerable <ILayer> layers, string targetRoot) { this.layers = layers.ToDictionary(layer => layer.Id); mapper = new PathMapper("", targetRoot); var rand = new Random(); database = new LiteDatabase($"{DateTime.Now.Ticks}.{rand.Next()}.db"); collection = database.GetCollection <EntryDataDto>("entry"); collection.DeleteAll(); }
public KvStorage() { if (db == null) { db = AnnoDataBase.Db; col = db.GetCollection <AnnoKV>(); col.EnsureIndex(x => x.Id); col.EnsureIndex(x => x.Value); } }
/// <summary>Get an item from the referenced collection.</summary> T ICollectionRef <T> .Get(Guid id) { try { using LiteDatabase _liteDB = new LiteDatabase(RefConfig.Location); ILiteCollection <T> _collection = _liteDB.GetCollection <T>(RefConfig.Collection); return(_collection.FindById(id)); } catch (Exception ex) { throw ex; } }
public void InitCollections() { accountsCollection = database.GetCollection <AccountInfoLiteDb>("accounts"); accountsCollection.EnsureIndex(a => a.Id, true); resetCodesCollection = database.GetCollection <PasswordResetDataLiteDb>("resetCodes"); resetCodesCollection.EnsureIndex(a => a.Email, true); emailConfirmationCodesCollection = database.GetCollection <EmailConfirmationDataLiteDb>("emailConfirmationCodes"); emailConfirmationCodesCollection.EnsureIndex(a => a.Email, true); }
public DatabaseMappingSource(YarnVersion yarnVersion, ILiteCollection <Mapping> classes, ILiteCollection <Mapping> fields, ILiteCollection <Mapping> methods) { YarnVersion = yarnVersion; _classes = classes; _fields = fields; _methods = methods; _classes.EnsureIndex(mapping => mapping.IntermediaryName); _fields.EnsureIndex(mapping => mapping.IntermediaryName); _methods.EnsureIndex(mapping => mapping.IntermediaryName); }
/// <summary> /// Arrange db, controller, and collection /// </summary> public void SetUp() { context = new LiteDBContext(); genericRepo = new GenericRepo <TextureModel>(context); textures = context.litedb.GetCollection <TextureModel>("textures"); if (textures.Count() == 0) { context.LoadDefaultTextureDirectoryIntoDatabase(textures); } repo = new TextureRepo(context, genericRepo); }
public void GlobalSetup() { File.Delete(DatabasePath); DatabaseInstance = new LiteDatabase(ConnectionString()); _fileMetaCollection = DatabaseInstance.GetCollection <FileMetaBase>(); _fileMetaCollection.EnsureIndex(file => file.IsFavorite); _fileMetaCollection.EnsureIndex(file => file.ShouldBeShown); _data = FileMetaGenerator <FileMetaBase> .GenerateList(DatasetSize); }
public ObjectId SaveWithoutUpdate(ConfigEntity config) { ILiteCollection <ConfigEntity> collection = db.GetCollection <ConfigEntity>(); ObjectId result = null; if (!collection.Exists(x => x.ConfigName.Equals(config.ConfigName))) { result = collection.Insert(config); } return(result); }