[hyena/canvas] [Hyena.Data.Sqlite] Add UpdateSelectionAggregates to cache



commit d17550bcc4fb0848c98241906b177221e1cff7aa
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Tue Oct 26 17:42:33 2010 -0500

    [Hyena.Data.Sqlite] Add UpdateSelectionAggregates to cache
    
    Lets you get aggregate information about the selected items (where
    before you could only get it for all the items in the cache).

 .../Hyena.Data.Sqlite/SqliteModelCache.cs          |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/Hyena.Data.Sqlite/Hyena.Data.Sqlite/SqliteModelCache.cs b/Hyena.Data.Sqlite/Hyena.Data.Sqlite/SqliteModelCache.cs
index e171362..e184e60 100644
--- a/Hyena.Data.Sqlite/Hyena.Data.Sqlite/SqliteModelCache.cs
+++ b/Hyena.Data.Sqlite/Hyena.Data.Sqlite/SqliteModelCache.cs
@@ -439,18 +439,32 @@ namespace Hyena.Data.Sqlite
 
         public void UpdateAggregates ()
         {
-            using (IDataReader reader = connection.Query (count_command, uid)) {
+            rows = UpdateAggregates (AggregatesUpdated, uid);
+        }
+
+        public void UpdateSelectionAggregates (Action<IDataReader> handler)
+        {
+            SaveSelection ();
+            UpdateAggregates (handler, selection_uid);
+        }
+
+        private long UpdateAggregates (Action<IDataReader> handler, long model_id)
+        {
+            long aggregate_rows = 0;
+            using (IDataReader reader = connection.Query (count_command, model_id)) {
                 if (reader.Read ()) {
-                    rows = Convert.ToInt64 (reader[0]);
+                    aggregate_rows = Convert.ToInt64 (reader[0]);
 
-                    Action<IDataReader> handler = AggregatesUpdated;
                     if (handler != null) {
                         handler (reader);
                     }
                 }
             }
+
+            return aggregate_rows;
         }
 
+
         private long FindOrCreateCacheModelId (string id)
         {
             long model_id = connection.Query<long> (String.Format (



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]