Beispiel #1
0
 public override bool CustomUpload(SqlBase con, SqlBase targetcon, TableMapping map)
 {
     if (targetcon is not SQLServerConnection)
     {
         return(true);
     }
     return(Execute().GetAwaiter().GetResult().ToResponse().ResponseResult == APIResponseResult.OK);
 }
Beispiel #2
0
        public void Add(TableMapping mapping, DaemonCompiledSetter daemonCompiledSetter)
        {
            int index = Mappings.IndexOf(mapping);

            if (index >= 0)
            {
                MappingsSetters[index] = daemonCompiledSetter;
            }
        }
Beispiel #3
0
 public abstract List <T> ExecuteQuery <T>(TableMapping map);
Beispiel #4
0
 public abstract IEnumerable <T> ExecuteDeferredQuery <T>(TableMapping map);
Beispiel #5
0
 public static NotNullConstraintViolationException New(SQLiteException exception, Kit.Sql.Base.TableMapping mapping, object obj)
 {
     return(new NotNullConstraintViolationException(exception.Result, exception.Message, mapping, obj));
 }
Beispiel #6
0
 public static NotNullConstraintViolationException New(SQLite3.Result r, string message, Kit.Sql.Base.TableMapping mapping, object obj)
 {
     return(new NotNullConstraintViolationException(r, message, mapping, obj));
 }
Beispiel #7
0
 protected NotNullConstraintViolationException(SQLite3.Result r, string message, Kit.Sql.Base.TableMapping mapping, object obj)
     : base(r, message)
 {
     if (mapping != null && obj != null)
     {
         this.Columns = from c in mapping.Columns
                        where c.IsNullable == false && c.GetValue(obj) == null
                        select c;
     }
 }
Beispiel #8
0
 protected TableQuery(SqlBase conn, TableMapping table)
 {
     Connection = conn;
     Table      = table;
 }
Beispiel #9
0
 public virtual bool CustomUpload(SqlBase con, SqlBase targetcon, Kit.Sql.Base.TableMapping map)
 {
     return(false);
 }
Beispiel #10
0
 public virtual void Delete(SqlBase con, SqlBase targetcon, Kit.Sql.Base.TableMapping map)
 {
     targetcon.Delete(this);
 }
Beispiel #11
0
 public override List <T> ExecuteQuery <T>(Kit.Sql.Base.TableMapping map)
 {
     return(ExecuteDeferredQuery <T>(map).ToList());
 }
Beispiel #12
0
        public override IEnumerable <T> ExecuteDeferredQuery <T>(Kit.Sql.Base.TableMapping map)
        {
            List <T> result = new List <T>();

            if (_conn.IsClosed)
            {
                _conn.RenewConnection();
            }

            Log.Logger.Debug(this.CommandText);
            var stmt = Prepare();

            try
            {
                var cols = new Column[SQLite3.ColumnCount(stmt)];
                var fastColumnSetters = new Action <T, sqlite3_stmt, int> [SQLite3.ColumnCount(stmt)];

                for (int i = 0; i < cols.Length; i++)
                {
                    var name = SQLite3.ColumnName16(stmt, i);
                    cols[i] = map.FindColumn(name);
                    if (cols[i] != null)
                    {
                        fastColumnSetters[i] = FastColumnSetter.GetFastSetter <T>(_conn, cols[i]);
                    }
                }

                while (SQLite3.Step(stmt) == SQLite3.Result.Row)
                {
                    var obj = Activator.CreateInstance(map.MappedType);
                    for (int i = 0; i < cols.Length; i++)
                    {
                        if (cols[i] == null)
                        {
                            continue;
                        }

                        if (fastColumnSetters[i] != null)
                        {
                            if (obj is not T)
                            {
                            }
                            fastColumnSetters[i].Invoke((T)obj, stmt, i);
                        }
                        else
                        {
                            var colType = SQLite3.ColumnType(stmt, i);
                            var val     = ReadCol(stmt, i, colType, cols[i].ColumnType);
                            cols[i].SetValue(obj, val);
                        }
                    }

                    OnInstanceCreated(obj);
                    result.Add((T)obj);
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "SqliteCommand.ExecuteDeferredQuery");
            }
            finally
            {
                SQLite3.Finalize(stmt);
            }

            return(result);
        }
Beispiel #13
0
 public SchemaTable Add(TableMapping map)
 {
     Mappings.Add(map);
     MappingsSetters.Add(null);
     return(this);
 }
 protected SQLServerTableQuery(SqlBase conn, Kit.Sql.Base.TableMapping table) : base(conn, table)
 {
 }
Beispiel #15
0
 public SQLiteTableQuery(SqlBase conn, Kit.Sql.Base.TableMapping table) : base(conn, table)
 {
 }