/// <summary> /// Initialize database using any read/write Stream (like MemoryStream) /// </summary> public LiteDatabase(Stream stream, BsonMapper mapper = null) { LitePlatform.ThrowIfNotInitialized(); _mapper = mapper ?? BsonMapper.Global; _engine = new LazyLoad <DbEngine>(() => new DbEngine(new StreamDiskService(stream), _log)); }
static LiteDatabase() { if (LitePlatform.Platform == null) { LitePlatform.Initialize(new Platform.LitePlatformDotNetStandardDefault()); } }
internal EntityBuilder(BsonMapper mapper) { LitePlatform.ThrowIfNotInitialized(); _mapper = mapper; _prop = mapper.GetPropertyMapper(typeof(T)); }
/// <summary> /// Starts LiteDB database using a connection string for filesystem database /// </summary> public LiteDatabase(string connectionString, BsonMapper mapper = null) { LitePlatform.ThrowIfNotInitialized(); var conn = new ConnectionString(connectionString); _mapper = mapper ?? BsonMapper.Global; var encrypted = !StringExtensions.IsNullOrWhiteSpace(conn.GetValue <string>("password", null)); _engine = new LazyLoad <DbEngine>(() => new DbEngine(encrypted ? new EncryptedDiskService(conn, _log) : new FileDiskService(conn, _log), _log)); }