コード例 #1
0
        public static Task Restart(this ILiteEngine liteEngine)
        {
            liteEngine.Stop();
            liteEngine.Start();

            return(Task.CompletedTask);
        }
コード例 #2
0
 internal LiteQueryable(ILiteEngine engine, BsonMapper mapper, string collection, Query query)
 {
     _engine     = engine;
     _mapper     = mapper;
     _collection = collection;
     _query      = query;
 }
コード例 #3
0
ファイル: LiteCollection.cs プロジェクト: fopsys/LiteDB
        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;
                }
            }
        }
コード例 #4
0
ファイル: LiteDatabase.cs プロジェクト: DrTtnk/LiteDB
        /// <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.");
                }
            }
        }
コード例 #5
0
 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)));
 }
コード例 #6
0
        /// <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;
        }
コード例 #7
0
 public Worker(
     ILiteEngine liteEngine,
     IOptions <CommonSettings> settings,
     ILogger <Worker> logger,
     IServiceProvider services)
 {
     _liteEngine       = liteEngine;
     _settingsRegistry = settings.Value;
     _services         = services;
     _logger           = logger;
 }
コード例 #8
0
        /// <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;
        }
コード例 #9
0
 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();
     }
 }
コード例 #10
0
ファイル: LiteDatabase.cs プロジェクト: heliomarpm/LiteDB
        /// <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;
        }
コード例 #11
0
ファイル: LiteDatabase.cs プロジェクト: heliomarpm/LiteDB
        /// <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;
        }
コード例 #12
0
        /// <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;
        }
コード例 #13
0
 /// <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;
 }
コード例 #14
0
 /// <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;
 }
コード例 #15
0
 /// <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;
 }
コード例 #16
0
ファイル: SqlParser.cs プロジェクト: tiandizhijian/LiteDB
 public SqlParser(ILiteEngine engine, Tokenizer tokenizer, BsonDocument parameters)
 {
     _engine     = engine;
     _tokenizer  = tokenizer;
     _parameters = parameters ?? new BsonDocument();
 }
コード例 #17
0
 public SysQuery(ILiteEngine engine) : base("$query")
 {
     _engine = engine;
 }
コード例 #18
0
ファイル: DataContext.cs プロジェクト: cm4ker/ET
 public DataContext(ILiteEngine engine, BsonMapper mapper = null, bool disposeOnClose = true) : base(engine,
                                                                                                     mapper, disposeOnClose)
 {
 }
コード例 #19
0
 internal RealtimeLiteEngine(ILiteEngine engine)
 {
     _engine = engine;
 }