Exemplo n.º 1
0
 public DbProvider(string databaseName, SqliteSettings settings)
 {
     DatabaseName        = databaseName;
     _enforceForeignKeys = settings.EnforceForeignKeys;
     _sqliteDatabasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), databaseName);
     _connectionProvider = new DbConnectionProvider(_sqliteDatabasePath, settings);
 }
Exemplo n.º 2
0
        public DbConnectionProvider(string sqlFile, SqliteSettings sqliteSettings)
        {
            var dataSource = $"Data Source={sqlFile};";
            var sqliteConnectionStringBuilder = new SqliteConnectionStringBuilder(dataSource)
            {
                CacheSize      = sqliteSettings.CacheSize,
                JournalMode    = GetJournalMode(sqliteSettings.JournalMode),
                PageSize       = sqliteSettings.PageSize,
                DefaultTimeout = (int)sqliteSettings.DefaultTimeout.TotalMilliseconds,
                SyncMode       = GetSyncMode(sqliteSettings.SyncMode),
                FailIfMissing  = sqliteSettings.FailIfMissing,
                ReadOnly       = sqliteSettings.ReadOnly,
            };

            _connectionString = sqliteConnectionStringBuilder.ConnectionString;
        }