Пример #1
0
        internal IEnumerable <T> ExecuteDeferredQuery <T>() where T : IDictionary <string, object>
        {
            if (_conn.Trace)
            {
                Debug.WriteLine("Executing Query: " + this);
            }

            var stmt = Prepare();

            try
            {
                var cols = new TableMapping.Column[SQLite3.ColumnCount(stmt)];
                // We have a valid row, get the correct datatypes and columns
                if (SQLite3.Step(stmt) == SQLite3.Result.Row)
                {
                    for (int i = 0; i < cols.Length; i++)
                    {
                        var name = SQLite3.ColumnName16(stmt, i);
                        cols[i] = new TableMapping.Column(name, SQLiteTypeConverter.convertTypeToCLRType(SQLite3.ColumnType(stmt, i)));
                    }
                }
                else
                {
                    yield break;
                }

                do
                {
                    IDictionary <string, object> obj = new Dictionary <string, object>();
                    for (int i = 0; i < cols.Length; i++)
                    {
                        if (cols[i] == null)
                        {
                            continue;
                        }
                        var colType = SQLite3.ColumnType(stmt, i);
                        var val     = ReadCol(stmt, i, colType, cols[i].ColumnType);
                        cols[i].SetValue(obj, val);
                    }
                    yield return((T)obj);
                } while (SQLite3.Step(stmt) == SQLite3.Result.Row);
            }
            finally
            {
                SQLite3.Finalize(stmt);
            }
        }
Пример #2
0
 void Finalize(Sqlite3Statement stmt)
 {
     SQLite3.Finalize(stmt);
 }