Ejemplo n.º 1
0
        public static void CreateAndRegister(AstNode astNode, LoweringContext context)
        {
            var astQuerySourceNode = astNode as AstQuerySourceNode;
            if (astQuerySourceNode != null)
            {
                var oleDBSource = new OleDBSource(context, astNode) { _oleDBConnection = new OleDBConnection(astQuerySourceNode.Connection) };

                // Note: vsabella: workaround for different behavior regarding expressions for OLEDB sources 
                // versus how it works in Lookups.
                if (astQuerySourceNode.Query.QueryType == QueryType.Expression)
                {
                    // Variable name has to be only alphanumeric, more restrictive than astQuerySource Name
                    string varName = "__" + System.Guid.NewGuid().ToString("N");
                    var variable = new Variable(varName);
                    oleDBSource.SqlCommandVarName = "User::" + varName;

                    variable.TypeCode = System.TypeCode.String;
                    variable.EvaluateAsExpression = true;
                    variable.ValueString = astQuerySourceNode.Query.Body;
                    context.ParentObject.Children.Add(variable);
                }
                else
                {
                    foreach (AstVariableParameterMappingNode paramNode in astQuerySourceNode.Query.Parameters)
                    {
                        var variable = new Variable(paramNode.Variable);
                        oleDBSource._paramDictionary[paramNode.Name] = variable;
                        context.ParentObject.Children.Add(variable);
                    }
                }

                context.ParentObject.Children.Add(oleDBSource._oleDBConnection);
                context.ParentObject.Children.Add(oleDBSource);
            }
        }
Ejemplo n.º 2
0
        public static void CreateAndRegister(AstNode astNode, LoweringContext context)
        {
            var astQuerySourceNode = astNode as AstQuerySourceNode;

            if (astQuerySourceNode != null)
            {
                var oleDBSource = new OleDBSource(context, astNode)
                {
                    _oleDBConnection = new OleDBConnection(astQuerySourceNode.Connection)
                };

                // Note: vsabella: workaround for different behavior regarding expressions for OLEDB sources
                // versus how it works in Lookups.
                if (astQuerySourceNode.Query.QueryType == QueryType.Expression)
                {
                    // Variable name has to be only alphanumeric, more restrictive than astQuerySource Name
                    string varName  = "__" + System.Guid.NewGuid().ToString("N");
                    var    variable = new Variable(varName);
                    oleDBSource.SqlCommandVarName = "User::" + varName;

                    variable.TypeCode             = System.TypeCode.String;
                    variable.EvaluateAsExpression = true;
                    variable.ValueString          = astQuerySourceNode.Query.Body;
                    context.ParentObject.Children.Add(variable);
                }
                else
                {
                    foreach (AstVariableParameterMappingNode paramNode in astQuerySourceNode.Query.Parameters)
                    {
                        var variable = new Variable(paramNode.Variable);
                        oleDBSource._paramDictionary[paramNode.Name] = variable;
                        context.ParentObject.Children.Add(variable);
                    }
                }

                context.ParentObject.Children.Add(oleDBSource._oleDBConnection);
                context.ParentObject.Children.Add(oleDBSource);
            }
        }