public virtual IEnumerable<T> Select<T>(SelectQuery selectQuery)\r
{\r
var rowObjectCreator = selectQuery.GetRowObjectCreator<T>();\r
- Console.WriteLine("# rowObjectCreator={0}", rowObjectCreator.Method);\r
- Console.WriteLine("# rowObjectCreator.Target={0}", rowObjectCreator.Target.GetType().FullName);\r
+\r
+ IList<T> results = new List<T>();\r
\r
// handle the special case where the query is empty, meaning we don't need the DB\r
if (string.IsNullOrEmpty(selectQuery.Sql.ToString()))\r
{\r
- yield return rowObjectCreator(null, null);\r
- yield break;\r
+ results.Add(rowObjectCreator(null, null));\r
}\r
-\r
- using (var dbCommand = selectQuery.GetCommand())\r
+ else\r
{\r
-\r
- // write query to log\r
- selectQuery.DataContext.WriteLog(dbCommand.Command);\r
-\r
- using (var reader = dbCommand.Command.ExecuteReader())\r
+ using (var dbCommand = selectQuery.GetCommand())\r
{\r
- while (reader.Read())\r
+ // write query to log\r
+ selectQuery.DataContext.WriteLog(dbCommand.Command);\r
+\r
+ using (var reader = dbCommand.Command.ExecuteReader())\r
{\r
- // someone told me one day this could happen (in SQLite)\r
- if (reader.FieldCount == 0)\r
- continue;\r
-\r
- var row = rowObjectCreator(reader, selectQuery.DataContext._MappingContext);\r
- // the conditions to register and watch an entity are:\r
- // - not null (can this happen?)\r
- // - registered in the model\r
- if (row != null && selectQuery.DataContext.Mapping.GetTable(row.GetType()) != null)\r
+ while (reader.Read())\r
{\r
- row = (T)selectQuery.DataContext.Register(row);\r
+ // someone told me one day this could happen (in SQLite)\r
+ if (reader.FieldCount == 0)\r
+ continue;\r
+\r
+ var row = rowObjectCreator(reader, selectQuery.DataContext._MappingContext);\r
+ // the conditions to register and watch an entity are:\r
+ // - not null (can this happen?)\r
+ // - registered in the model\r
+ if (row != null && selectQuery.DataContext.Mapping.GetTable(row.GetType()) != null)\r
+ {\r
+ row = (T)selectQuery.DataContext.Register(row);\r
+ }\r
+ results.Add(row);\r
}\r
-\r
- yield return row;\r
}\r
}\r
}\r
+ return results;\r
}\r
\r
/// <summary>\r