Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InMemorySQLiteDatabase"/> class.
        /// </summary>
        public InMemorySQLiteDatabase()
        {
            var connectionStringBuilder = new SQLiteConnectionStringBuilder
            {
                DataSource = ":memory:",
                Version = 3,
                DefaultTimeout = 5,
                JournalMode = SQLiteJournalModeEnum.Memory,
                UseUTF16Encoding = true
            };

            sharedConnection = new SQLiteConnection(connectionStringBuilder.ConnectionString);
            sharedConnection.OpenAndReturn();
            sqlRunner = new AdHocSqlRunner(() => sharedConnection.CreateCommand(), null, () => true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TemporarySQLiteDatabase"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public TemporarySQLiteDatabase(string name)
        {
            dataSourcePath = Path.Combine(Environment.CurrentDirectory, name);

            var connectionStringBuilder = new SQLiteConnectionStringBuilder
            {
                DataSource = name,
                Version = 3,
                DefaultTimeout = 5,
                JournalMode = SQLiteJournalModeEnum.Memory,
                UseUTF16Encoding = true
            };

            sqLiteConnection = new SQLiteConnection(connectionStringBuilder.ConnectionString);
            sharedConnection = new SharedConnection(sqLiteConnection.OpenAndReturn());
            sqlRunner = new AdHocSqlRunner(() => sqLiteConnection.CreateCommand(), null, () => true);
        }
Exemplo n.º 3
0
        public static void Connect()
        {
            bool existsBeforeConnection = File.Exists("Ledger.db");

            SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
            builder.DataSource = "Ledger.db";
            builder.Version = 3;
            builder.FailIfMissing = false;

            SQLiteConnection connection = new SQLiteConnection();
            connection.ConnectionString = builder.ConnectionString;
            Connection = connection.OpenAndReturn();

            if (!existsBeforeConnection)
            {
                CreateUsersTable();
                CreateRecordsTable();
            }
        }
 public DatabaseConnectionDescriptor(string dbFilePath)
 {
     _connection = new SQLiteConnection(ConnectionStringBuilder.CreateWithDataSource(dbFilePath));
     _connection.OpenAndReturn().Execute("PRAGMA case_sensitive_like=1");
 }