forked from fpvmorais/EzApi2016
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EzHelpers.cs
73 lines (68 loc) · 2.88 KB
/
EzHelpers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask;
namespace Microsoft.SqlServer.SSIS.EzAPI
{
public static class EzHelpers
{
/// <summary>
/// Extension method that adds Microsoft.SqlServer.Dts.Runtime.Variable with expression to the Microsoft.SqlServer.Dts.Runtime.Variables
// collection.
/// </summary>
/// <param name="vars"></param>
/// <param name="name"></param>
/// <param name="evaluateasexpression"></param>
/// <param name="nameSpace"></param>
/// <param name="expression"></param>
/// <returns>Variable</returns>
public static Variable Add(this Variables vars, string name, string nameSpace, string expression)
{
Variable x = vars.Add(name, false, nameSpace, string.Empty);
x.Expression = expression;
x.EvaluateAsExpression = true;
x.Name = name;
x.Namespace = nameSpace;
return x;
}
/// <summary>
/// Extension method to easily add parameters bindings to ExecSQLTask
/// </summary>
/// <param name="binds"></param>
/// <param name="parameterName"></param>
/// <param name="dtsVariableName"></param>
/// <param name="dataType"></param>
public static void Add(this IDTSParameterBindings binds, string parameterName, string dtsVariableName, OleDBDataTypes dataType)
{
IDTSParameterBinding x = binds.Add();
x.ParameterName = parameterName;
x.DtsVariableName = dtsVariableName;
x.DataType = (int)dataType;
}
/// <summary>
/// Extension method to easily add parameters bindings with direction to ExecSQLTask
/// </summary>
/// <param name="binds"></param>
/// <param name="parameterName"></param>
/// <param name="dtsVariableName"></param>
/// <param name="dataType"></param>
public static void Add(this IDTSParameterBindings binds, ParameterDirections direction, string parameterName, string dtsVariableName, OleDBDataTypes dataType)
{
IDTSParameterBinding x = binds.Add();
x.ParameterName = parameterName;
x.DtsVariableName = dtsVariableName;
x.ParameterDirection = direction;
x.DataType = (int)dataType;
}
/// <summary>
/// Extension method to easily add result bindings to ExecSQLTask
/// </summary>
/// <param name="binds"></param>
/// <param name="resultName"></param>
/// <param name="dtsVariableName"></param>
public static void Add(this IDTSResultBindings binds, string resultName, string dtsVariableName)
{
IDTSResultBinding x = binds.Add();
x.ResultName = resultName;
x.DtsVariableName = dtsVariableName;
}
}
}