base.preexecute(); 是什么意思?或者 base.postexecute() 实际上呢?

What does base.preexecute(); or base.postexecute() actually do?

当我在 SSIS 中创建一个新的脚本组件时,preexecute 和 post execute 方法包含 base.PreExecute();和 base.PostExecute();行...

我想知道这些行的作用,以及对 modifying/removing 它们的影响。谢谢!

我无法准确地告诉您这两个基本方法在做什么,但是这个 answer 讨论了所有 SSIS 任务组件的生命周期:

All the tasks/containers in an SSIS have the same lifecycle. You can see some of this by watching the Event Handlers fire. In a script component, inside a Data Flow Task, is going to under go various steps. Part of that is Validation (this contract says I should have a column from this table that is an integer type- can I connect, does it exist, is it the right type, etc).

After validation, tasks will have setup and tear down steps to perform. Since you appear to be working with SSIS Variables in your script, part of that pre/post execute time is spent allowing the translation of Variable (SSIS) to variable (.net) and back again.

因此,我认为您不应该删除它们,除非您有特定要求不进行 SSIS 的默认预处理和 post 处理。

tl;博士;

对于当前版本的 Integration Services,这些是无操作方法。当前删除它们的后果将不存在。但是,Microsoft 可能随时在这些方法中添加对集成服务的健康至关重要的操作(通过补丁不太可能,通过发布新版本更不可能)。他们在 2008 年、2012 年或 2014 年都没有这样做,但 v.Next 未知。

除非你有充分的理由不花瞬间闪烁击中基本方法,否则我会把它留在那儿。

l;r

一个脚本组件,创建一个 ScriptMain class 派生自 UserComponent 派生自 ScriptComponent

UserComponent 由 Visual Studio 自动生成,只要您 create/modify 脚本组件的输入和输出。

/* THIS IS AUTO-GENERATED CODE THAT WILL BE OVERWRITTEN! DO NOT EDIT!
*  Microsoft SQL Server Integration Services component wrapper
*  This module defines the base class for your component
*  THIS IS AUTO-GENERATED CODE THAT WILL BE OVERWRITTEN! DO NOT EDIT! */

ScriptMain 是您的游乐场,您可以在其中选择性地调用 base.pre/postexecute 方法。

根据您的版本,ScriptComponent 来自 Microsoft.SqlServer.TxScript.dll

  • C:\Program Files (x86)\Microsoft SQL Server\{VersionNumber}\DTS\PipelineComponents\Microsoft.SqlServer.TxScript.dll

在 Pre/PostExecute 组件上按 F12 会转到

public class ScriptComponent
{
    public virtual void PostExecute();
    public virtual void PreExecute();
}

我启动了 ILSpy,根据它,那些方法是空的

// Microsoft.SqlServer.Dts.Pipeline.ScriptComponent
public virtual void PostExecute()
{
}

// Microsoft.SqlServer.Dts.Pipeline.ScriptComponent
public virtual void PreExecute()
{
}

刷新我对 virtual (C# reference)

的记忆

The virtual keyword is used to modify a method, property, indexer, or event declaration and allow for it to be overridden in a derived class. For example, this method can be overridden by any class that inherits it: