Example #1
0
        public int Insert(OracleConnection connection, object[] args)
        {
            if (args.Length % 2 != 0)
            {
                throw new ArgumentException("number of args must be even");
            }

            int M = args.Length / 2;

            switch (M)
            {
            case 1:
                var statement1 = $"insert into {table} ({args[0]}) values (:0)";
                return(QM.Insert(connection, statement1, new object[] { args[1] }));

            case 2:
                var statement2 = $"insert into {table} ({args[0]},{args[2]}) values (:0, :1)";
                return(QM.Insert(connection, statement2, new object[] { args[1], args[3] }));

            case 3:
                var statement3 = $"insert into {table} ({args[0]},{args[2]},{args[4]}) values (:0, :1, :2)";
                return(QM.Insert(connection, statement3, new object[] { args[1], args[3], args[5] }));

            case 4:
                var statement4 = $"insert into {table} ({args[0]},{args[2]},{args[4]},{args[6]}) values (:0, :1, :2, :3)";
                return(QM.Insert(connection, statement4, new object[] { args[1], args[3], args[5], args[7] }));

            default:
                throw new NotImplementedException($"M = {M}");
            }
        }
Example #2
0
        internal IEnumerable <int> QueryIntegerArray(OracleConnection connection, string column, object[] conditions)
        {
            switch (conditions.Length)
            {
            case 2:
                var sql2 = $"select {column} from {table} where {conditions[0].ToString()}=:0";
                return(QM.QueryIntegerArray(connection, sql2, new object[] { conditions[1] }));

            case 4:
                var sql4 = $"select {column} from {table} where {conditions[0].ToString()}=:0 and {conditions[2].ToString()}=:1";
                return(QM.QueryIntegerArray(connection, sql4, new object[] { conditions[1], conditions[3] }));

            default:
                throw new NotImplementedException($"length = {conditions.Length}");
            }
        }
Example #3
0
        public IEnumerable <int> QueryPrimaryKeyArray(OracleConnection connection, string where0, object value0, string where1, object value1)
        {
            var column = QM.GetPkName(connection, table);

            return(QueryIntegerArray(connection, column, where0, value0, where1, value1));
        }
Example #4
0
 public DateTime?QueryDateTime(OracleConnection connection, string column, int id) => QM.QueryDateTime(connection, column, table, id);
Example #5
0
 public string QueryString(OracleConnection connection, string column, int id) => QM.QueryString(connection, column, table, id);
Example #6
0
 public string QueryString(OracleConnection connection, string column, object[] conditions) => QM.QueryString(connection, column, table, conditions);
Example #7
0
 public int?QueryInteger(OracleConnection connection, string column, int id) => QM.QueryInteger(connection, column, table, id);
Example #8
0
 public int?QueryInteger(OracleConnection connection, string column, object[] conditions) => QM.QueryInteger(connection, column, table, conditions);
Example #9
0
        public bool Exists(OracleConnection connection, int id)
        {
            var pkname = QM.GetPkName(connection, table);

            return(QueryInteger(connection, pkname, id) != null);;
        }
Example #10
0
 public void DeleteAll(OracleConnection connection)
 {
     QM.DML(connection, $"delete {table}");
 }
Example #11
0
        public IEnumerable <Tuple <T1, T2> > QueryAll <T1, T2>(OracleConnection connection, string column0, string column1)
        {
            var sql = $"select {column0}, {column1} from {table}";

            return(QM.QueryArray <T1, T2>(connection, sql, new object[0]));
        }
Example #12
0
 public int Count(OracleConnection connection)
 {
     return((int)QM.QueryInteger(connection, $"select count(*) from {table}", new object[0]));
 }
Example #13
0
 public void Update(OracleConnection connection, int Id, string column, object value)
 {
     QM.Update(connection, table, Id, column, value);
 }