public async Task TestTimeSpan()
 {
     var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
     var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), true);
     var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));
     await TestAsyncDateTime(db);
 }
 public void AsyncAsTicks ()
 {
     var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
     var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), false);
     var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));
     TestAsyncDateTimeOffset (db);
 }
Example #3
0
        public Database(ISQLitePlatform platform, string databasePath)
        {
            _connectionParameters = new SQLiteConnectionString(databasePath, false);
            _sqliteConnectionPool = new SQLiteConnectionPool(platform);

            _dbConnection = new SQLiteAsyncConnection(() => _sqliteConnectionPool.GetConnection(_connectionParameters));
        }
Example #4
0
        public void AsyncAsTicks()
        {
            var sqLiteConnectionPool   = new SQLiteConnectionPool(new SQLitePlatformWin32());
            var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), true);
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));

            TestAsyncDateTime(db);
        }
Example #5
0
        public async Task AsyncAsString()
        {
            var sqLiteConnectionPool   = new SQLiteConnectionPool(new SQLitePlatformTest());
            var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), false);
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));

            await TestAsyncDateTime(db, sqLiteConnectionString.StoreDateTimeAsTicks);
        }
        public async Task TestTimeSpan()
        {
            var sqLiteConnectionPool   = new SQLiteConnectionPool(new SQLitePlatformTest());
            var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), true);
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));

            await TestAsyncDateTime(db);
        }
        public static SQLiteDataReader select(string sql)
        {
            SQLiteCommand sQLiteCommand = new SQLiteCommand();

            sQLiteCommand.CommandText = sql;
            sQLiteCommand.Connection  = SQLiteConnectionPool.getConnection();
            return(sQLiteCommand.ExecuteReader());
        }
        public static void execute(string sql)
        {
            SQLiteCommand sQLiteCommand = new SQLiteCommand();

            sQLiteCommand.CommandText = sql;
            sQLiteCommand.Connection  = SQLiteConnectionPool.getConnection();
            Console.WriteLine($"执行成功,{sQLiteCommand.ExecuteNonQuery()}行受到影响");
        }
Example #9
0
        public DataService(IDeviceInfo deviceInfo, SQLite.Net.Interop.ISQLitePlatform platform)
        {
            _deviceInfo       = deviceInfo;
            _platform         = platform;
            _path             = Path.Combine(_deviceInfo.DatabasePath, DBNAME);
            _connectionString = new SQLiteConnectionString(_path, true);
            _connectionPool   = new SQLiteConnectionPool(_platform);

            this.CreateTablesIfRequired();
        }
Example #10
0
        public async Task UnicodePathsAsync()
        {
            string path = Path.GetTempFileName() + UnicodeText;

            var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(new SQLiteConnectionString(path, true)));
            await db.CreateTableAsync <OrderLine>();

            Assert.That(new FileInfo(path).Length, Is.GreaterThan(0), path);
        }
Example #11
0
        public void UnicodePathsAsync()
        {
            string path = Path.GetTempFileName() + UnicodeText;

            var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformWin32());
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(new SQLiteConnectionString(path, true)));
            db.CreateTableAsync<OrderLine>().Wait();

            Assert.That(new FileInfo(path).Length, Is.GreaterThan(0), path);
        }
Example #12
0
        public SqliteEventStore(ISQLitePlatform sqLitePlatform, string databasePath, GetUtcNow getUtcNow = null)
        {
            Ensure.That(sqLitePlatform, "sqLitePlatform").IsNotNull();
            Ensure.That(databasePath, "databasePath").IsNotNull();

            _getUtcNow      = getUtcNow ?? SystemClock.GetUtcNow;
            _connectionPool = new SQLiteConnectionPool(sqLitePlatform);
            var connectionString = new SQLiteConnectionString(databasePath, false);

            _getConnection = () => _connectionPool.GetConnection(connectionString);
        }
Example #13
0
        public void SetUp()
        {
            if (_sqliteConnectionPool != null)
            {
                _sqliteConnectionPool.Reset();
            }
            _path = Path.Combine(Path.GetTempPath(), DatabaseName);
            // delete old db file
            File.Delete(_path);

            _connectionParameters = new SQLiteConnectionString(_path, false);
            _sqliteConnectionPool = new SQLiteConnectionPool(_sqlite3Platform);
        }
Example #14
0
        public void SetUp()
        {
            if (_sqliteConnectionPool != null)
            {
                _sqliteConnectionPool.Reset();
            }
            _path = Path.Combine(Path.GetTempPath(), DatabaseName);
            // delete old db file
            File.Delete(_path);

            _connectionParameters = new SQLiteConnectionString(_path, false);
            _sqliteConnectionPool = new SQLiteConnectionPool(_sqlite3Platform);
        }
Example #15
0
        private SQLiteAsyncConnection CreateSqliteAsyncConnection()
        {
            var sqliteFilename = "MyDatabase.db3";
            var libraryPath    = _configuration.DbPath;

//#if __ANDROID__
//				string libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); ;
//#else
//            // we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
//            // (they don't want non-user-generated data in Documents)
//            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder
//            string libraryPath = Path.Combine(documentsPath, "../Library/");
//#endif
            var sqLitePath = Path.Combine(libraryPath, sqliteFilename);

            var connectionString     = new SQLiteConnectionString(sqLitePath, true);
            var sqLiteConnectionPool = new SQLiteConnectionPool(_configuration.SQLitePlatform);

            Debug.WriteLine(string.Format("sqlitePath: {0}", sqLitePath));

            return(new SQLiteAsyncConnection(() =>
                                             sqLiteConnectionPool.GetConnection(connectionString)));
        }
Example #16
0
 public void TestFixtureSetUp()
 {
     _sqlite3Platform = new SQLitePlatformTest();
     _sqliteConnectionPool = new SQLiteConnectionPool(_sqlite3Platform);
 }
Example #17
0
 public Database()
 {
     mainPool = new SQLiteConnectionPool(MAX_CONNECTIONS, DatabasePath);
     logPool  = new SQLiteConnectionPool(MAX_CONNECTIONS, QuerylogPath);
 }
 /// <summary>
 /// Create a new connection pool lock
 /// </summary>
 public ConnectionPoolLockBox(SQLiteConnectionPool pool)
 {
     this.m_pool = pool;
     Monitor.Enter(this.m_pool.m_lockObject);
 }
Example #19
0
 public void TestFixtureSetUp()
 {
     _sqlite3Platform      = new SQLitePlatformWin32();
     _sqliteConnectionPool = new SQLiteConnectionPool(_sqlite3Platform);
 }
Example #20
0
 public static void SetConnectionPool(SQLiteConnectionPool connectionPool)
 {
     _connectionPool = connectionPool;
 }
 public async Task AsyncAsString()
 {
     var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
     var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), false);
     var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));
     await TestAsyncDateTime(db, sqLiteConnectionString.StoreDateTimeAsTicks);
 }