예제 #1
0
        public static void SetTemporaryFilesDirectory(SqliteSessionBase session, string directoryPath)
        {
#if NETFX_CORE
            SetDirectory(DirectoryType.Temp, directoryPath);
#elif SILVERLIGHT || WINDOWS_PHONE
            session.Execute("PRAGMA temp_store_directory = ?;", directoryPath);
#else
#endif
        }
예제 #2
0
 public static Task <T> ExecuteScalarAsync <T>(this SqliteSessionBase session, string sql, params object[] args)
 {
     return(Task <T> .Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.ExecuteScalar <T>(sql, args);
         }
     }));
 }
예제 #3
0
 public static Task <int> ExecuteAsync(this SqliteSessionBase session, string query, params object[] args)
 {
     return(Task <int> .Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.Execute(query, args);
         }
     }));
 }
예제 #4
0
 public static Task <int> ClearTableAsync <T>(this SqliteSessionBase session) where T : new()
 {
     return(Task.Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.ClearTable <T>();
         }
     }));
 }
예제 #5
0
 public static Task <int> DeleteAsync <T>(this SqliteSessionBase session, T item)
 {
     return(Task.Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.Delete(item);
         }
     }));
 }
예제 #6
0
 public static Task <int> CreateTableAsync <T>(this SqliteSessionBase session, bool createIndexes = true) where T : new()
 {
     return(Task <int> .Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.CreateTable <T>(createIndexes);
         }
     }));
 }
예제 #7
0
 public static Task <bool> TableExistsAsync <T>(this SqliteSessionBase session) where T : new()
 {
     return(Task <bool> .Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.TableExists <T>();
         }
     }));
 }
예제 #8
0
 public static Task <int> UpdateAllAsync <T>(this SqliteSessionBase session, string propertyName, object propertyValue)
 {
     return(Task.Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.UpdateAll <T>(propertyName, propertyValue);
         }
     }));
 }
예제 #9
0
 public static Task <List <T> > QueryAsync <T>(this SqliteSessionBase session, string sql, params object[] args) where T : new()
 {
     return(Task <List <T> > .Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.Query <T>(sql, args);
         }
     }));
 }
예제 #10
0
 public static Task <int> InsertDefaultsAsync <T>(this SqliteSessionBase session) where T : class
 {
     return(Task.Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.InsertDefaults <T>();
         }
     }));
 }
예제 #11
0
 public static Task <int> InsertAsync <T>(this SqliteSessionBase session, T item, ConflictResolution extra)
 {
     return(Task.Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.Insert(item, extra);
         }
     }));
 }
예제 #12
0
 public static Task <int> InsertAllAsync <T>(this SqliteSessionBase session, IEnumerable <T> items)
 {
     return(Task.Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.InsertAll(items);
         }
     }));
 }
예제 #13
0
 public static Task <T> FindAsync <T>(this SqliteSessionBase session, object pk, params object[] primaryKeys) where T : new()
 {
     return(Task.Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.Find <T>(pk, primaryKeys);
         }
     }));
 }
예제 #14
0
 public static Task <T> GetAsync <T>(this SqliteSessionBase session, Expression <Func <T, bool> > expression) where T : new()
 {
     return(Task.Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             return session.Get(expression);
         }
     }));
 }
예제 #15
0
 public static Task OpenAsync(this SqliteSessionBase session)
 {
     return(Task.Factory.StartNew(
                () =>
     {
         using (session.Lock())
         {
             session.Open();
         }
     }));
 }
예제 #16
0
        /// <summary>
        ///   To avoid spiky INSERT performance, an application can run the
        ///   "merge=X,Y" command periodically, possibly in an idle thread or
        ///   idle process.
        ///   The idle thread that is running the merge commands can know when
        ///   it is done by checking the difference in sqlite3_total_changes()
        ///   before and after each "merge=X,Y" command and stopping the loop
        ///   when the difference drops below two.
        /// </summary>
        /// <param name="database">The database to use.</param>
        /// <param name="type">
        ///   The table on which to perform the merges.
        /// </param>
        public static int RunMergeUntilOptimal(this SqliteSessionBase database, Type type)
        {
            int changes = 0;
            int i;

            while ((i = database.Merge(type)) >= 2)
            {
                changes += i;
            }
            return(changes);
        }
예제 #17
0
        /// <summary>
        ///   The "integrity-check" command causes SQLite to read and verify
        ///   the accuracy of all inverted indices in an FTS3/4 table by
        ///   comparing those inverted indices against the original content.
        /// </summary>
        /// <param name="database">The database to use.</param>
        /// <param name="type">The table to check.</param>
        public static int IntegrityCheck(this SqliteSessionBase database, Type type)
        {
            var map = database.GetMapping(type);

            return(database.Execute(String.Format(IntegrityCheckCommand, map.TableName)));
        }
예제 #18
0
 /// <summary>
 ///   The "integrity-check" command causes SQLite to read and verify
 ///   the accuracy of all inverted indices in an FTS3/4 table by
 ///   comparing those inverted indices against the original content.
 /// </summary>
 /// <typeparam name="T">The table to check.</typeparam>
 /// <param name="database">The database to use.</param>
 public static int IntegrityCheck <T>(this SqliteSessionBase database)
 {
     return(database.IntegrityCheck(typeof(T)));
 }
예제 #19
0
        /// <summary>
        ///   The "rebuild" command causes SQLite to discard the entire FTS3/4
        ///   table and then rebuild it again from original text.
        ///   The concept is similar to REINDEX.
        /// </summary>
        /// <param name="database">The database to use.</param>
        /// <param name="type">The table to rebuild.</param>
        public static int Rebuild(this SqliteSessionBase database, Type type)
        {
            var map = database.GetMapping(type);

            return(database.Execute(String.Format(RebuildCommand, map.TableName)));
        }
예제 #20
0
 /// <summary>
 ///   The "rebuild" command causes SQLite to discard the entire FTS3/4
 ///   table and then rebuild it again from original text.
 ///   The concept is similar to REINDEX.
 /// </summary>
 /// <typeparam name="T">The table to rebuild.</typeparam>
 /// <param name="database">The database to use.</param>
 public static int Rebuild <T>(this SqliteSessionBase database)
 {
     return(database.Rebuild(typeof(T)));
 }
예제 #21
0
 /// <summary>
 ///   The "optimize" command causes FTS3/4 to merge together all of its
 ///   inverted index b-trees into one large and complete b-tree.
 /// </summary>
 /// <typeparam name="T">The table to optimize.</typeparam>
 /// <param name="database">The database to use.</param>
 public static int Optimize <T>(this SqliteSessionBase database)
 {
     return(database.Optimize(typeof(T)));
 }
예제 #22
0
        /// <summary>
        ///   The "automerge=B" command disables or enables automatic
        ///   incremental inverted index merging for an FTS3/4 table.
        ///   Enabling automatic incremental merge causes SQLite to do a small
        ///   amount of inverted index merging after every INSERT operation to
        ///   prevent spiky INSERT performance.
        /// </summary>
        /// <param name="database">The database to use.</param>
        /// <param name="type">
        ///   The table on which to enable/disable the merges.
        ///  </param>
        /// <param name="enable">
        ///   True to enable automatic incremental inverted index. False to
        ///   disable.
        /// </param>
        public static int AutoMerge(this SqliteSessionBase database, Type type, bool enable = false)
        {
            var map = database.GetMapping(type);

            return(database.Execute(String.Format(AutoMergeCommand, map.TableName, enable ? 1 : 0)));
        }
예제 #23
0
 /// <summary>
 ///   The "automerge=B" command disables or enables automatic
 ///   incremental inverted index merging for an FTS3/4 table.
 ///   Enabling automatic incremental merge causes SQLite to do a small
 ///   amount of inverted index merging after every INSERT operation to
 ///   prevent spiky INSERT performance.
 /// </summary>
 /// <typeparam name="T">
 ///   The table on which to enable/disable the merges.
 /// </typeparam>
 /// <param name="database">The database to use.</param>
 /// <param name="enable">
 ///   True to enable automatic incremental inverted index. False to
 ///   disable.
 /// </param>
 public static int AutoMerge <T>(this SqliteSessionBase database, bool enable = false)
 {
     return(database.AutoMerge(typeof(T), enable));
 }
예제 #24
0
 /// <summary>
 ///   To avoid spiky INSERT performance, an application can run the
 ///   "merge=X,Y" command periodically, possibly in an idle thread or
 ///   idle process.
 ///   The idle thread that is running the merge commands can know when
 ///   it is done by checking the difference in sqlite3_total_changes()
 ///   before and after each "merge=X,Y" command and stopping the loop
 ///   when the difference drops below two.
 /// </summary>
 /// <typeparam name="T">
 ///   The table on which to perform the merges.
 /// </typeparam>
 /// <param name="database">The database to use.</param>
 public static int RunMergeUntilOptimal <T>(this SqliteSessionBase database)
 {
     return(database.RunMergeUntilOptimal(typeof(T)));
 }
예제 #25
0
        /// <summary>
        ///   The "merge=X,Y" command (where X and Y are integers) causes
        ///   SQLite to do a limited amount of work toward merging the various
        ///   inverted index b-trees of an FTS3/4 table together into one large
        ///   b-tree.
        /// </summary>
        /// <param name="database">The database to use.</param>
        /// <param name="type">The table on which to perform the merge.</param>
        /// <param name="x">
        ///   The X value is the target number of "blocks" to be merged.
        ///   The value of X can be any positive integer but values on the
        ///   order of 100 to 300 are recommended.
        /// </param>
        /// <param name="y">
        ///   The Y is the minimum number of b-tree segments on a level
        ///   required before merging will be applied to that level.
        ///   The value of Y should be between 2 and 16 with a recommended
        ///   value of 8.
        /// </param>
        public static int Merge(this SqliteSessionBase database, Type type, int x = 100, int y = 8)
        {
            var map = database.GetMapping(type);

            return(database.Execute(String.Format(MergeXyCommand, map.TableName, x, y)));
        }
예제 #26
0
 /// <summary>
 ///   The "merge=X,Y" command (where X and Y are integers) causes
 ///   SQLite to do a limited amount of work toward merging the various
 ///   inverted index b-trees of an FTS3/4 table together into one large
 ///   b-tree.
 /// </summary>
 /// <typeparam name="T">
 ///   The table on which to perform the merge.
 /// </typeparam>
 /// <param name="database">The database to use.</param>
 /// <param name="x">
 ///   The X value is the target number of "blocks" to be merged.
 ///   The value of X can be any positive integer but values on the
 ///   order of 100 to 300 are recommended.
 /// </param>
 /// <param name="y">
 ///   The Y is the minimum number of b-tree segments on a level
 ///   required before merging will be applied to that level.
 ///   The value of Y should be between 2 and 16 with a recommended
 ///   value of 8.
 /// </param>
 public static int Merge <T>(this SqliteSessionBase database, int x = 100, int y = 8)
 {
     return(database.Merge(typeof(T), x, y));
 }
예제 #27
0
 public TableQuery(SqliteSessionBase session)
     : this(session, session.GetMapping <T>())
 {
 }
예제 #28
0
 private TableQuery(SqliteSessionBase session, TableMapping table)
 {
     this.Session = session;
     this.Table   = table;
 }