Exemplo n.º 1
0
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:SQL クエリのセキュリティ脆弱性を確認")]
        private void ExecuteSql(string sql, NpgsqlParameter[] paramList, IChangeSet owner, IChangeSetRow row, NpgsqlConnection connection, NpgsqlTransaction transaction)
        {
            LastSql       = sql;
            LastParameter = paramList;
            NpgsqlCommand cmd = new NpgsqlCommand(sql, connection, transaction);

            cmd.Parameters.AddRange(paramList);
            using (IDataReader reader = cmd.ExecuteReader())
            {
                if (reader.FieldCount == 0)
                {
                    return;
                }
                int[] idxList = new int[reader.FieldCount];
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    ColumnInfo fi = owner.GetFieldByName(reader.GetName(i));
                    idxList[i] = (fi != null) ? fi.Index : -1;
                }
                row.Read(reader, idxList);
            }
        }