我基于Andy Leonard 的 Incremental Load framework的旧版本做了类似的事情。我们的子包填充一个记录集,指示我们有多少新的、更改的、未更改的等行数。在父包中,我们测试该对象以确保在使用它之前已填充它。我需要跳到一个会议,所以请原谅这段代码,因为它不能完全解决您的特定需求,但希望能在正确的方向上提供坚实的推动力,直到我可以回来为您的情况量身定制。我在那里有你想做的事情的伪代码。
    public void Main()
    {
        bool debug = Convert.ToBoolean(Dts.Variables["Debug"].Value);
        string taskName = string.Empty;
        string packageName = string.Empty;
        string sourceName = string.Empty;
        bool fireAgain = false;
        taskName = Convert.ToString(Dts.Variables["TaskName"].Value);
        packageName = Convert.ToString(Dts.Variables["PackageName"].Value);
        // Fix this by defining and passing in params
        sourceName = Convert.ToString(Dts.Variables["TaskName"].Value);
        System.Data.OleDb.OleDbDataAdapter adapater = null;
        System.Data.DataTable table = null;
        System.Data.DataColumn column = null;
        System.Data.DataRow row = null;
        string message = string.Empty;
        object rowCounts = null;
        rowCounts = Dts.Variables["RowCounts"].Value;
        table = new DataTable();
        try
        {
            // Get us out of this crazy thing - should only be an issue
            // first pass through
            if (rowCounts == null)
            {
                Dts.TaskResult = (int)ScriptResults.Success;
                return;
            }
        }
        catch (Exception ex)
        {
            throw new Exception("Failed here");
        }
        adapater = new System.Data.OleDb.OleDbDataAdapter();
        try
        {
            // This works if we pass in a dataset
            //adapater.Fill(table, Dts.Variables["RowCounts"].Value);
            adapater.Fill(table, rowCounts);
            // TODO: Enumerate through adapter
            // Call Output0Buffer.AddRow();
            // and Output0Buffer.MyColumn.Value = adapter[i].value // possibly casting to strong type
        }
        catch (Exception ex)
        {
            try
            {
                // This works if we use a datatable
                System.Data.DataSet ds = null;
                //ds = (DataSet)Dts.Variables["RowCounts"].Value;
                ds = (DataSet)rowCounts;
                table = ds.Tables[0];
                // TODO: Enumerate through datatable as we do with adapter
            }
            catch (Exception innerException)
            {
                // continue to swallow exceptions
            }
            Dts.Variables["ValidCounts"].Value = false;
            // trap "Object is not an ADODB.RecordSet or an ADODB.Record
            // parse ex.Message
            if (ex.Message.Contains("System.ArgumentException: "))
            {
                System.Text.StringBuilder exceptionMessage = null;
                exceptionMessage = new System.Text.StringBuilder();
                exceptionMessage.Append(ex.Message);
                exceptionMessage.Replace("\nParameter name: adodb", string.Empty);
                exceptionMessage.Replace("System.ArgumentException: ", string.Empty);
                if (exceptionMessage.ToString() != "Object is not an ADODB.RecordSet")
                {
                    Dts.Events.FireInformation(0, string.Format("{0}.{1}", packageName, taskName), exceptionMessage.ToString(), string.Empty, 0, ref fireAgain);
                }
            }
        }
        Dts.Variables["ValidCounts"].Value = false;
        if (table.Rows.Count > 0)
        {
            Dts.Variables["ValidCounts"].Value = true;
        }
        if (debug)
        {
            message = string.Format("SourceName:  {0}\nValidCounts:  {1}", sourceName, false);
            //System.Windows.Forms.MessageBox msgBox = null;
            //msgBox = new MessageBox();
            System.Windows.Forms.MessageBox.Show(message, string.Format("{0}.{1}", packageName, taskName));
            //MessageBox(message, string.Format("{0}.{1}", packageName, taskName));
        }
        Dts.TaskResult = (int)ScriptResults.Success;
    }