コード例 #1
0
        public virtual IDbCommand INSERT_withoutId(DBConnection db, string tableName, DBItem item)
        {
            IDbCommand command = Command;

            IEnumerable <string> columnNames = item.getColumnNames().Except(new string[] { PrimaryKey, FullPrimaryKey(tableName, false) });

            command.CommandText =
                $"INSERT INTO {ToRealTableName(db.Application, tableName)}({string.Join(",", columnNames.Select(c => AddQuote(c)))}) " +
                $"VALUES ({string.Join(",", columnNames.Select(key => $"@{command.AddParam(key, item[key])}"))});";

            return(command);
        }
コード例 #2
0
        public override IDbCommand INSERT(DBConnection db, string tableName, DBItem item)
        {
            MySqlCommand command = new MySqlCommand();

            IEnumerable <string> columnNames = item.getColumnNames().Except(new string[] { PrimaryKey, FullPrimaryKey(tableName, false) });

            command.CommandText =
                $"INSERT INTO {ToRealTableName(db.Application, tableName)}({string.Join(",", columnNames.Select(c => AddQuote(c)))}) " +
                $"VALUES ({string.Join(",", columnNames.Select(c => $"@{command.AddParam(c, item[c])}"))});" +
                $"SELECT LAST_INSERT_ID() {PrimaryKey};";

            return(command);
        }