I've created a Package with a SSIS Data flow (Designer mode) named 'User', witch have a ADO.NET source from table 'User' to a ADO.NET Destination table 'UserDest' (columns: id, name). Table columns are identically. Then I have to re-create this same structure of Dataflow to other 100 remaining tables (Creating precedence constraints aditionally, because the import must be done one table per time). My idea is to edit the Package via C#, Clone the structure of the 'User' Data flow, adjust the columns mapping and the ADO.NET table source and destination.
I've started creating a Package variable to start cloning the properties, but the InnerObject returns null:
using System;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
namespace ConsoleApplication1
{
public class Gerador
{
public string RunPackage2()
{
var pkgLocation = @"C:\Users\me\Documents\Visual Studio 2015\Projects\SSISExample1\SSISExample1\Package.dtsx";
Application app = new Application();
Package pkg = app.LoadPackage(pkgLocation, null);
var importUsersHost = pkg.Executables[0] as TaskHost;
var pipe = importUsersHost.InnerObject as MainPipe; // Here it returns null
Console.WriteLine();
return "OK";
}
}
}
In resume, I need to generate 100 other Data flows like the 'Users' Data flow, and add a connector one after other (because each Data flow must run one by one).