Using SQLite connection RRS feed

  • Question

  • Dear all,

    IN an univeral app project, I am using SQLite databse for the first time and have to say that I am a bit confuse and need to be sure of proper way to go.

    First of all, I am using on my share project the SQLite.Net.dll assembly version v2.5.1.0

    I have a SQLiteDataService class which is in charge of  initialising a database connection as follow :

    public class SQLiteDataService
            private IStorageService _storageService;
            private SQLite.Net.Async.SQLiteAsyncConnection _connectionAsync;
            private ISQLitePlatform _sqlitePlatform;
            public SQLite.Net.Async.SQLiteAsyncConnection dbConnection { get; set; }
            public SQLiteDataService(ISQLitePlatform sqlitePlatform, IStorageService storageService)
                this._sqlitePlatform = sqlitePlatform;
                this._storageService = storageService;
            public async Task InitializeAsync()
                if (_connectionAsync == null)
                    string databaseFile = await _storageService.GetPathForFileAsync("App.sqlite");
                    _connectionAsync = new SQLite.Net.Async.SQLiteAsyncConnection(() =>
                        new SQLiteConnectionWithLock(_sqlitePlatform, new SQLiteConnectionString(databaseFile, false)));
                    dbConnection = _connectionAsync;

    I am using Ioc in my project and in this class I need to pass the ISqlitePlatform object and IStorageService.
    ISQLite object is needed to initialise the SQLiteConnectionWithLock and IStorage service is an interface that each project ( WinRt and WP) implement to retrive database file base on environement.

    The problem I am stuck in is how can get this ISQLitePlatform object to be pass in the constructor?


    Wednesday, April 8, 2015 8:02 AM