public static Task Restart(this ILiteEngine liteEngine) { liteEngine.Stop(); liteEngine.Start(); return(Task.CompletedTask); }
internal LiteQueryable(ILiteEngine engine, BsonMapper mapper, string collection, Query query) { _engine = engine; _mapper = mapper; _collection = collection; _query = query; }
internal LiteCollection(string name, BsonAutoId autoId, ILiteEngine engine, BsonMapper mapper) { _collection = name ?? mapper.ResolveCollectionName(typeof(T)); _engine = engine; _mapper = mapper; _includes = new List <BsonExpression>(); // if strong typed collection, get _id member mapped (if exists) if (typeof(T) == typeof(BsonDocument)) { _entity = null; _id = null; _autoId = autoId; } else { _entity = mapper.GetEntityMapper(typeof(T)); _id = _entity.Id; if (_id != null && _id.AutoId) { _autoId = _id.DataType == typeof(Int32) || _id.DataType == typeof(Int32?) ? BsonAutoId.Int32 : _id.DataType == typeof(Int64) || _id.DataType == typeof(Int64?) ? BsonAutoId.Int64 : _id.DataType == typeof(Guid) || _id.DataType == typeof(Guid?) ? BsonAutoId.Guid : BsonAutoId.ObjectId; } else { _autoId = BsonAutoId.ObjectId; } } }
/// <summary> /// Starts LiteDB database using a connection string for file system database /// </summary> public LiteDatabase(ConnectionString connectionString, BsonMapper mapper = null) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } if (connectionString.Upgrade == true) { // try upgrade if need LiteEngine.Upgrade(connectionString.Filename, connectionString.Password); } _engine = connectionString.CreateEngine(); _mapper = mapper ?? BsonMapper.Global; _disposeOnClose = true; if (connectionString.Collation != null) { var current = this.Collation.ToString(); if (connectionString.Collation.ToString() != current) { this.Dispose(); throw new LiteException(0, $"Database collation '{current}' is different from connection string. Use Rebuild database to change collation."); } } }
public SqlParser(ILiteEngine engine, Tokenizer tokenizer, BsonDocument parameters) { _engine = engine; _tokenizer = tokenizer; _parameters = parameters ?? new BsonDocument(); _collation = new Lazy <Collation>(() => new Collation(_engine.Pragma(Pragmas.COLLATION))); }
/// <summary> /// Starts LiteDB database using custom ILiteEngine implementation /// </summary> public LiteDatabase(ILiteEngine engine, BsonMapper mapper = null) { if (engine == null) { throw new ArgumentNullException(nameof(engine)); } _engine = new Lazy <ILiteEngine>(() => engine); _mapper = mapper ?? BsonMapper.Global; }
public Worker( ILiteEngine liteEngine, IOptions <CommonSettings> settings, ILogger <Worker> logger, IServiceProvider services) { _liteEngine = liteEngine; _settingsRegistry = settings.Value; _services = services; _logger = logger; }
/// <summary> /// Starts LiteDB database using a generic Stream implementation (mostly MemoryStream). /// </summary> /// <param name="stream">DataStream reference </param> /// <param name="mapper">BsonMapper mapper reference</param> /// <param name="logStream">LogStream reference </param> public LiteDatabase(Stream stream, BsonMapper mapper = null, Stream logStream = null) { var settings = new EngineSettings { DataStream = stream ?? throw new ArgumentNullException(nameof(stream)), }; _engine = new LiteEngine(settings); _mapper = mapper ?? BsonMapper.Global; _disposeOnClose = true; }
public RealtimeLiteDatabase(ILiteEngine engine, BsonMapper?mapper = null) : base(engine, mapper) { if (engine is RealtimeLiteEngine realtimeEngine) { _engine = realtimeEngine; _engine.NotificationService.Init(this); } else { throw new NotSupportedException(); } }
/// <summary> /// Starts LiteDB database using a generic Stream implementation (mostly MemoryStrem). /// Use another MemoryStrem as LOG file. /// </summary> public LiteDatabase(Stream stream, BsonMapper mapper = null) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } var settings = new EngineSettings { DataStream = stream }; _engine = new LiteEngine(settings); _mapper = mapper ?? BsonMapper.Global; }
/// <summary> /// Starts LiteDB database using a connection string for file system database /// </summary> public LiteDatabase(ConnectionString connectionString, BsonMapper mapper = null) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } if (connectionString.Upgrade != UpgradeOption.False) { // try upgrade if need LiteEngine.Upgrade(connectionString.Filename, connectionString.Password, connectionString.Upgrade); } _engine = connectionString.CreateEngine(); _mapper = mapper ?? BsonMapper.Global; }
/// <summary> /// Starts LiteDB database using a connection string for file system database /// </summary> public LiteDatabase(ConnectionString connectionString, BsonMapper mapper = null) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } if (connectionString.Upgrade == true) { // try upgrade if need LiteEngine.Upgrade(connectionString.Filename, connectionString.Password, connectionString.Collation); } _engine = connectionString.CreateEngine(); _mapper = mapper ?? BsonMapper.Global; _disposeOnClose = true; }
/// <summary> /// Start LiteDB database using a pre-exiting engine. When LiteDatabase instance dispose engine instance will be disposed too /// </summary> public LiteDatabase(ILiteEngine engine, BsonMapper mapper = null, bool disposeOnClose = true) { _engine = engine ?? throw new ArgumentNullException(nameof(engine)); _mapper = mapper ?? BsonMapper.Global; _disposeOnClose = disposeOnClose; }
/// <summary> /// Create new instance of LiteDatabase using an external Stream source as database file /// </summary> public LiteDatabase(Stream stream, Collation collation = null, BsonMapper mapper = null) { _engine = new LiteEngine(stream, collation); _mapper = mapper ?? BsonMapper.Global; }
/// <summary> /// Start LiteDB database using a pre-exiting engine. When LiteDatabase instance dispose engine instance will be disposed too /// </summary> public LiteDatabase(ILiteEngine engine, BsonMapper mapper = null) { _engine = engine; _mapper = mapper ?? BsonMapper.Global; }
public SqlParser(ILiteEngine engine, Tokenizer tokenizer, BsonDocument parameters) { _engine = engine; _tokenizer = tokenizer; _parameters = parameters ?? new BsonDocument(); }
public SysQuery(ILiteEngine engine) : base("$query") { _engine = engine; }
public DataContext(ILiteEngine engine, BsonMapper mapper = null, bool disposeOnClose = true) : base(engine, mapper, disposeOnClose) { }
internal RealtimeLiteEngine(ILiteEngine engine) { _engine = engine; }