Beispiel #1
0
        public IEnumerable <T> ExecuteDeferredQuery <T> (TableMapping map)
        {
            if (_conn.Trace)
            {
                _conn.Tracer?.Invoke("Executing Query: " + this);
            }

            var stmt = Prepare();

            try {
                var cols = new TableMapping.Column [SQLite3.ColumnCount(stmt)];

                for (int i = 0; i < cols.Length; i++)
                {
                    var name = SQLite3.ColumnName16(stmt, i);
                    cols [i] = map.FindColumn(name);
                }

                while (SQLite3.Step(stmt) == Result.Row)
                {
                    var obj = Activator.CreateInstance(map.MappedType);
                    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);
                    }
                    OnInstanceCreated(obj);
                    yield return((T)obj);
                }
            } finally {
                SQLite3.Finalize(stmt);
            }
        }
Beispiel #2
0
 public TableQuery(SQLiteConnection conn)
 {
     Connection = conn;
     Table      = Connection.GetMapping(typeof(T));
 }
Beispiel #3
0
 TableQuery(SQLiteConnection conn, TableMapping table)
 {
     Connection = conn;
     Table      = table;
 }
Beispiel #4
0
 public List <T> ExecuteQuery <T> (TableMapping map)
 {
     return(ExecuteDeferredQuery <T> (map).ToList());
 }
 public static NotNullConstraintViolationException New(SQLiteException exception, TableMapping mapping, object obj)
 {
     return(new NotNullConstraintViolationException(exception.Result, exception.Message, mapping, obj));
 }
 public static NotNullConstraintViolationException New(Result r, string message, TableMapping mapping, object obj)
 {
     return(new NotNullConstraintViolationException(r, message, mapping, obj));
 }