SSIS异步转换保留前一列值并设置到下一行
SSIS Asynchronous Transformation keep the previous column value and set to the next line
刚刚在 SSIS 中使用异步转换时遇到一个问题。为了简化问题,假设我只有两个输出,"Name" 和 "Id".
我的 C# 代码是:
string name = "";
string Id = "";
if(...) // read the first line to get Name and partial value of "Id"
{
Output0Buffer.AddRow();
Output0Buffer.Name = Row.Name.Trim();
Id = Row.Id.Trim();
}
else if(...) //read the 2nd line to get the rest part of "Id"
{
Output0Buffer.Id = Id + Row.Id.Trim();
}
所以理想情况下,当两个输出填充 Output0Buffer 时,"Name" 和 "Id" 将被输出,但问题是,当第 2 行被读入缓冲区时,它会初始化 String Id
,所以串联 Output0Buffer.Id = Id + Row.Id.Trim();
不起作用。 (它就像 "" + rest part of the Id
一样工作,因为第一部分被初始化,第二部分是当前值)
我现在想坚持使用脚本组件转换,请问有什么办法可以解决吗?
@Brad 的思路是正确的,但您需要将 Id 的声明移动到 class 级别成员,而不是在 ... SendOutputBuffer 或它所调用的任何内容中。
如果您的 if 语句,则需要测试 Name 是否与 class 级别成员 Name 匹配。
您需要确保您有 read/write 访问 OutputBuffer0 列的权限。我不记得异步组件的默认值是什么 - 可能只是写。
大局,您将所有值 (ID) 连接成一个大字符串并将其与键(名称)相关联,是吗?
哦,为了提高性能,将 Id 声明为 StringBuilder 并在将其分配给输出缓冲区时仅转换为 String 可能会更好
刚刚在 SSIS 中使用异步转换时遇到一个问题。为了简化问题,假设我只有两个输出,"Name" 和 "Id".
我的 C# 代码是:
string name = "";
string Id = "";
if(...) // read the first line to get Name and partial value of "Id"
{
Output0Buffer.AddRow();
Output0Buffer.Name = Row.Name.Trim();
Id = Row.Id.Trim();
}
else if(...) //read the 2nd line to get the rest part of "Id"
{
Output0Buffer.Id = Id + Row.Id.Trim();
}
所以理想情况下,当两个输出填充 Output0Buffer 时,"Name" 和 "Id" 将被输出,但问题是,当第 2 行被读入缓冲区时,它会初始化 String Id
,所以串联 Output0Buffer.Id = Id + Row.Id.Trim();
不起作用。 (它就像 "" + rest part of the Id
一样工作,因为第一部分被初始化,第二部分是当前值)
我现在想坚持使用脚本组件转换,请问有什么办法可以解决吗?
@Brad 的思路是正确的,但您需要将 Id 的声明移动到 class 级别成员,而不是在 ... SendOutputBuffer 或它所调用的任何内容中。
如果您的 if 语句,则需要测试 Name 是否与 class 级别成员 Name 匹配。
您需要确保您有 read/write 访问 OutputBuffer0 列的权限。我不记得异步组件的默认值是什么 - 可能只是写。
大局,您将所有值 (ID) 连接成一个大字符串并将其与键(名称)相关联,是吗?
哦,为了提高性能,将 Id 声明为 StringBuilder 并在将其分配给输出缓冲区时仅转换为 String 可能会更好