using LiteDB; using skydiveLogs_api.Domain; using skydiveLogs_api.Infrastructure.Interfaces; namespace skydiveLogs_api.Infrastructure { public class LiteDbProvider : IDataProvider { public LiteDbProvider(string connectionString) { _db = new LiteDatabase(connectionString); BsonMapper.Global.Entity().DbRef(x => x.JumpType, "JumpType"); BsonMapper.Global.Entity().DbRef(x => x.Aircraft, "Aircraft"); BsonMapper.Global.Entity().DbRef(x => x.DropZone, "DropZone"); BsonMapper.Global.Entity().DbRef(x => x.Gear, "Gear"); BsonMapper.Global.Entity().DbRef(x => x.User, "User"); BsonMapper.Global.Entity().DbRef(x => x.User, "User"); BsonMapper.Global.Entity().DbRef(x => x.User, "User"); } public ILiteCollection GetCollection() { return _db.GetCollection(); } public void Close() { _db.Dispose(); } private readonly LiteDatabase _db; public ILiteCollection CollOfAircraft => _db.GetCollection(); public ILiteCollection CollOfDropZone => _db.GetCollection(); public ILiteCollection CollOfGear => _db.GetCollection(); public ILiteCollection CollOfJumpType => _db.GetCollection(); public ILiteCollection CollOfJump => _db.GetCollection(); public ILiteCollection CollOfUser => _db.GetCollection(); public ILiteCollection CollOfImage => _db.GetCollection(); } }