Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a new method "ExecuteDeferredQuery2", which will fetch the data… #748

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/SQLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2681,6 +2681,36 @@ public IEnumerable<T> ExecuteDeferredQuery<T> (TableMapping map)
}
}

public IEnumerable<Dictionary<string, object>> ExecuteDeferredQuery2 () {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer the name ExecuteDeferredGenericQuery

var stmt = Prepare ();
try {
var cols = new TableMapping.Column[SQLite3.ColumnCount (stmt)];
while (SQLite3.Step (stmt) == SQLite3.Result.Row) {
Dictionary<string, object> dict = new Dictionary<string, object> ();
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<T> ()
{
if (_conn.Trace) {
Expand Down