From 70a1deb7e82ec9264fdbd312618ca2a74b3eb746 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Madas Date: Mon, 27 Aug 2018 17:56:23 +0530 Subject: [PATCH] Added a new method "ExecuteDeferredQuery2", which will fetch the data into dictionaries. --- src/SQLite.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/SQLite.cs b/src/SQLite.cs index c276066f..98af4f8c 100644 --- a/src/SQLite.cs +++ b/src/SQLite.cs @@ -2681,6 +2681,36 @@ public IEnumerable ExecuteDeferredQuery (TableMapping map) } } + public IEnumerable> ExecuteDeferredQuery2 () { + var stmt = Prepare (); + try { + var cols = new TableMapping.Column[SQLite3.ColumnCount (stmt)]; + while (SQLite3.Step (stmt) == SQLite3.Result.Row) { + Dictionary dict = new Dictionary (); + for (var i = 0; i < cols.Length; i++) { + var name = SQLite3.ColumnName16 (stmt, i); + var colType = SQLite3.ColumnType (stmt, i); + Type type; + if (colType == SQLite3.ColType.Float) + type = typeof (float); + else if (colType == SQLite3.ColType.Blob) + type = typeof (object); + else if (colType == SQLite3.ColType.Integer) + type = typeof (Int64); + else + type = typeof (string); + var val = ReadCol (stmt, i, colType, type); + dict[name] = val; + + } + yield return dict; + } + } + finally { + SQLite3.Finalize (stmt); + } + } + public T ExecuteScalar () { if (_conn.Trace) {