Example #1
0
        public void TestBoolean()
        {
            var    sqlite3Platform = new SQLitePlatformWin32();
            string tmpFile         = TestPath.GetTempFileName();
            var    db = new DbAcs(sqlite3Platform, tmpFile);

            db.buildTable();
            for (int i = 0; i < 10; i++)
            {
                db.Insert(new VO
                {
                    Flag = (i % 3 == 0),
                    Text = String.Format("VO{0}", i)
                });
            }

            // count vo which flag is true
            Assert.AreEqual(4, db.CountWithFlag(true));
            Assert.AreEqual(6, db.CountWithFlag(false));

            Debug.WriteLine("VO with true flag:");
            foreach (VO vo in db.Query <VO>("SELECT * FROM VO Where Flag = ?", true))
            {
                Debug.WriteLine(vo.ToString());
            }

            Debug.WriteLine("VO with false flag:");
            foreach (VO vo in db.Query <VO>("SELECT * FROM VO Where Flag = ?", false))
            {
                Debug.WriteLine(vo.ToString());
            }
        }
Example #2
0
        public MainWindow()
        {
            SQLitePlatformWin32 litePlatform = new SQLitePlatformWin32();

            viewModel = new ViewModel(litePlatform, databasePath, File.Exists(databasePath));
            InitializeComponent();
        }
Example #3
0
        public override SQLiteConnection GetDatabase(string name)
        {
            ISQLitePlatform platform;

            if (RuntimeInfo.IsWindows)
            {
                platform = new SQLitePlatformWin32();
            }
            else
            {
                platform = new SQLitePlatformGeneric();
            }
            return(new SQLiteConnection(platform, @":memory:"));
        }
Example #4
0
        public override SQLiteConnection GetDatabase(string name)
        {
            ISQLitePlatform platform;

            if (RuntimeInfo.IsWindows)
            {
                platform = new SQLitePlatformWin32(Architecture.NativeIncludePath);
            }
            else
            {
                platform = new SQLitePlatformGeneric();
            }
            return(new SQLiteConnection(platform, GetUsablePathFor($@"{name}.db", true)));
        }
Example #5
0
        public override SQLiteConnection GetDatabase(string name)
        {
            Directory.CreateDirectory(BasePath);
            ISQLitePlatform platform;

            if (RuntimeInfo.IsWindows)
            {
                platform = new SQLitePlatformWin32();
            }
            else
            {
                platform = new SQLitePlatformGeneric();
            }
            return(new SQLiteConnection(platform, Path.Combine(BasePath, $@"{name}.db")));
        }
Example #6
0
        public override SQLiteConnection GetDatabase(string name, SQLiteOpenFlags openFlags = SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create,
                                                     bool storeDateTimeAsTicks = true, IBlobSerializer serializer = null,
                                                     IDictionary <string, TableMapping> tableMappings = null,
                                                     IDictionary <Type, string> extraTypeMappings     = null, IContractResolver resolver = null)
        {
            Directory.CreateDirectory(BasePath);
            ISQLitePlatform platform;

            if (RuntimeInfo.IsWindows)
            {
                platform = new SQLitePlatformWin32();
            }
            else
            {
                platform = new SQLitePlatformGeneric();
            }
            return(new SQLiteConnection(platform, Path.Combine(BasePath, $@"{name}.db"), openFlags, storeDateTimeAsTicks, serializer, tableMappings, extraTypeMappings, resolver));
        }
Example #7
0
        public SQLiteAsyncConnection GetAsyncConnection()
        {
            var dbPath = GetDatabasePath();

            var platForm = new SQLitePlatformWin32();

            var connectionFactory = new Func <SQLiteConnectionWithLock>(
                () =>
            {
                if (_conn == null)
                {
                    _conn =
                        new SQLiteConnectionWithLock(platForm,
                                                     new SQLiteConnectionString(dbPath, storeDateTimeAsTicks: true));
                }
                return(_conn);
            });
            var asyncConnection = new SQLiteAsyncConnection(connectionFactory);

            return(asyncConnection);
        }
Example #8
0
 public SQLitePlatformTest()
 {
     _sqlitePlatformWin32 = new SQLitePlatformWin32();
 }
Example #9
0
 public void TestFixtureSetUp()
 {
     _sqlite3Platform      = new SQLitePlatformWin32();
     _sqliteConnectionPool = new SQLiteConnectionPool(_sqlite3Platform);
 }
 public SQLitePlatformDesktop()
 {
     _sqlitePlatformWin32 = new SQLitePlatformWin32();
 }
Example #11
0
 public void SetUp()
 {
     _sqlite3Platform = new SQLitePlatformWin32();
 }