Esempio n. 1
0
        private string ToBaseSql(QueryItem query, IAmlSqlWriterSettings settings)
        {
            using (var writer = new StringWriter())
            {
                var visitor = new SqlServerVisitor(writer, settings);
                var clone   = new CloneVisitor().WithPropertyMapper(p =>
                {
                    var table = p.Table;
                    table.TryFillName(settings);
                    if (string.IsNullOrEmpty(table.Type))
                    {
                        return(IgnoreNode.Instance);
                    }
                    var props = settings.GetProperties(table.Type);
                    if (props.Count < 1)
                    {
                        return(p);
                    }
                    if (!props.TryGetValue(p.Name, out var propDefn))
                    {
                        return(IgnoreNode.Instance);
                    }
                    if (propDefn.DataType().Value == "foreign")
                    {
                        return(table.GetProperty(propDefn));
                    }
                    return(p);
                }).Clone(query);
                visitor.Visit(clone);

                writer.Flush();
                return(writer.ToString());
            }
        }
 public override bool IsMatch(FunctionObject node) {
     if (node.ParameterDeclarations != null &&
         node.ParameterDeclarations.Length >= 1) {
         var visitor = new CloneVisitor(node.ParameterDeclarations[0].VariableField);
         node.Walk(visitor);
         return visitor.ReturnsClonedVar;
     }
     return false;
 }