private void SetComponentProperties(OLEDBSource source) { switch (source.AccessMode) { case DataFlowSourceQueryAccessMode.SQLCOMMAND: _instance.SetComponentProperty("AccessMode", 2); _instance.SetComponentProperty("SqlCommand", source.Body); Flush(); break; case DataFlowSourceQueryAccessMode.SQLCOMMANDFROMVARIABLE: _instance.SetComponentProperty("AccessMode", 3); DTS.Variable sqlCommandVariable = SsisPackage.CurrentPackage.DTSPackage.Variables.Add( ("var"+Guid.NewGuid().ToString()).Replace("-", string.Empty) , false , "User" , string.Empty); sqlCommandVariable.EvaluateAsExpression = true; sqlCommandVariable.Expression = source.Body; _instance.SetComponentProperty("SqlCommandVariable", sqlCommandVariable.Name); Flush(); break; default: MessageEngine.Global.Trace(Severity.Error, "Unknown Source Data Access Mode Type of {0}", source.AccessMode); break; } }
public static PhysicalDataFlow.OLEDBSource Lower(this AstTransformation.AstQuerySourceNode astNode) { if (astNode.AsClassOnly) { return null; } PhysicalDataFlow.OLEDBSource physicalSource = new Ssis2008Emitter.IR.DataFlow.OLEDBSource(); physicalSource.Body = astNode.Query; AddConnection(astNode.Connection); physicalSource.Connection = astNode.Connection.Name; physicalSource.Name = astNode.Name; if (astNode.EvaluateAsExpression == true) { physicalSource.AccessMode = Ssis2008Emitter.IR.DataFlow.DataFlowSourceQueryAccessMode.SQLCOMMANDFROMVARIABLE; } else { physicalSource.AccessMode = Ssis2008Emitter.IR.DataFlow.DataFlowSourceQueryAccessMode.SQLCOMMAND; } foreach (AstTransformation.AstQuerySourceParameterNode parameter in astNode.Parameters) { PhysicalDataFlow.DataFlowSourceQueryParameter physicalParameter = new Ssis2008Emitter.IR.DataFlow.DataFlowSourceQueryParameter(); physicalParameter.Name = parameter.Name; physicalParameter.VariableName = parameter.Variable.Name; physicalParameter.Parent = physicalSource; physicalSource.ParameterMappings.Add(physicalParameter); } return physicalSource; }