[longomatch/redesign3: 153/156] Add a method to list and count objects in the DB



commit f1a83285daaa99cc527b9514dac724a7b09e753b
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Aug 18 00:11:51 2011 +0200

    Add a method to list and count objects in the DB

 LongoMatch/Services/DataBase.cs |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch/Services/DataBase.cs b/LongoMatch/Services/DataBase.cs
index 29aeb6b..d6cdd3d 100644
--- a/LongoMatch/Services/DataBase.cs
+++ b/LongoMatch/Services/DataBase.cs
@@ -81,6 +81,30 @@ namespace LongoMatch.DB
 			}
 		}
 		
+		public void ListObjects() {
+			Dictionary<Type, int> dict = new Dictionary<Type, int>();
+			IObjectContainer db = Db4oFactory.OpenFile(file);
+			
+			IQuery query = db.Query();
+			query.Constrain(typeof(object));
+			IObjectSet result = query.Execute();
+			while(result.HasNext()) {
+				var res = result.Next();
+				Type type = res.GetType();
+				
+				if (dict.ContainsKey(type))
+					dict[type]++;
+				else
+					dict.Add(type, 1);
+				
+			}
+			foreach (Type t in dict.Keys) {
+				Log.Information(t.ToString()+":" + dict[t]);
+			}
+			CloseDB(db);
+			
+		}
+		
 		/// <summary>
 		/// Initialize the Database
 		/// </summary>



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