gpt4 book ai didi

c# - Convert.ToString 返回 `System.Byte[]` 而不是实际数据,因为 GROUP_CONCAT 返回 BLOB

转载 作者:可可西里 更新时间:2023-11-01 07:59:13 25 4
gpt4 key购买 nike

我有一种调用MySQL 过程的方法。以下是程序的一部分:

SELECT AR.alert_id AS AlertId,
AR.rule_id AS RuleId,
AR.name AS RuleName,
AR.rule_type AS RuleType,
AR.description AS Description,
(SELECT group_concat(occured_event_id separator ', ')
FROM alert_rule_event
WHERE alert_rule_id = AR.id) AS OccuredEventIds,
FROM alert_rule AR

C#代码:

alertRuleEntity.AlertId = Convert.ToInt32(dtAlertRuleEntityList.Rows[index]["AlertId"]);
alertRuleEntity.RuleId = Convert.ToInt32(dtAlertRuleEntityList.Rows[index]["RuleId"]);
alertRuleEntity.RuleName = Convert.ToString(dtAlertRuleEntityList.Rows[index]["RuleName"]);
alertRuleEntity.RuleType = Convert.ToString(dtAlertRuleEntityList.Rows[index]["RuleType"]);
alertRuleEntity.Description = Convert.ToString(dtAlertRuleEntityList.Rows[index]["Description"]);
alertRuleEntity.OccuredEventIds = Convert.ToString(dtAlertRuleEntityList.Rows[index]["OccuredEventIds"]);

返回值如下:

enter image description here

它能够正确读取所有列值。但是对于 OccuredEventIds 列,它给出的值是 System.Byte[] 而不是它的实际值。可能是什么问题?

最佳答案

在对我的程序进行以下更改后,它起作用了:

(SELECT group_concat(CONVERT(occured_event_id, CHAR(8)) separator ', ') 
FROM alert_rule_event
WHERE alert_rule_id = AR.id) AS OccuredEventIds

关于c# - Convert.ToString 返回 `System.Byte[]` 而不是实际数据,因为 GROUP_CONCAT 返回 BLOB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16517366/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com