public NotNullConstraintViolationException(SQLiteException exception, TableMapping mapping, object obj) : this(exception.Result, exception.Message, mapping, obj)
 {
 }
 public ActiveInsertCommand(TableMapping tableMapping)
 {
     _tableMapping = tableMapping;
 }
Ejemplo n.º 3
0
 public List <T> ExecuteQuery <T>(TableMapping map)
 {
     return(ExecuteDeferredQuery <T>(map).ToList());
 }
Ejemplo n.º 4
0
 private TableQuery(SQLiteConnection conn, TableMapping table)
 {
     Connection = conn;
     Table      = table;
 }
Ejemplo n.º 5
0
        public IEnumerable <T> ExecuteDeferredQuery <T>(TableMapping map)
        {
            _conn.TraceListener.WriteLine("Executing Query: {0}", this);

            var stmt = Prepare();

            try
            {
                var cols            = new TableMapping.Column[sqlite.ColumnCount(stmt)];
                var type            = typeof(T);
                var isPrimitiveType = type.GetTypeInfo().IsPrimitive || type == typeof(string);

                for (var i = 0; i < cols.Length; i++)
                {
                    if (!isPrimitiveType)
                    {
                        var name = sqlite.ColumnName16(stmt, i);
                        cols[i] = map.FindColumn(name);
                    }
                    else
                    {
                        cols[i] = map.CreateColumn(type);
                    }
                }

                while (sqlite.Step(stmt) == Result.Row)
                {
                    var obj = isPrimitiveType ? null : _conn.Resolver.CreateObject(map.MappedType);
                    for (var i = 0; i < cols.Length; i++)
                    {
                        ColType colType;
                        object  val;

                        //Support of primitive types
                        if (isPrimitiveType)
                        {
                            //Assert(cols.Length == 1)
                            colType = sqlite.ColumnType(stmt, i);
                            val     = ReadCol(stmt, i, colType, cols[i].ColumnType);
                            yield return((T)Convert.ChangeType(val, type, CultureInfo.CurrentCulture));

                            break;
                        }

                        if (cols[i] == null)
                        {
                            continue;
                        }
                        colType = sqlite.ColumnType(stmt, i);
                        val     = ReadCol(stmt, i, colType, cols[i].ColumnType);
                        cols[i].SetValue(obj, val);
                    }

                    if (!isPrimitiveType)
                    {
                        OnInstanceCreated(obj);
                        yield return((T)obj);
                    }
                }
            }
            finally
            {
                sqlite.Finalize(stmt);
            }
        }