Exemple #1
0
        public string Resolve <T>(CommandNode command, T parameter) where T : class
        {
            var buffer = new StringBuilder();

            foreach (var item in command.Nodes)
            {
                if (item is TextNode)
                {
                    var txt = ResolveTextNode(item as TextNode);
                    if (txt.Length > 0)
                    {
                        buffer.AppendFormat($" {txt}");
                    }
                }
                else if (item is WhereNode)
                {
                    var txt = ResolveWhereNode(item as WhereNode, parameter);
                    if (txt.Length > 0)
                    {
                        buffer.AppendFormat($" {txt}");
                    }
                }
                else if (item is IfNode)
                {
                    var txt = ResolveIfNode(item as IfNode, parameter);
                    if (txt.Length > 0)
                    {
                        buffer.AppendFormat($" {txt}");
                    }
                }
            }
            return(buffer.ToString().Trim(' '));
        }
Exemple #2
0
        public string Resolve <T>(CommandNode command, T parameter) where T : class
        {
            var buffer   = new StringBuilder();
            var wheresql = string.Empty;

            foreach (var item in command.Nodes)
            {
                if (item is TextNode)
                {
                    var txt = ResolveTextNode(item as TextNode);
                    if (txt.Length > 0)
                    {
                        buffer.AppendFormat($" {txt}");
                    }
                }
                else if (item is WhereNode)
                {
                    wheresql = ResolveWhereNode(item as WhereNode, parameter);
                    if (wheresql.Length > 0)
                    {
                        buffer.AppendFormat($" {wheresql}");
                    }
                }
                else if (item is IfNode)
                {
                    var txt = ResolveIfNode(item as IfNode, parameter);
                    if (txt.Length > 0)
                    {
                        buffer.AppendFormat($" {txt}");
                    }
                }
            }
            if (command.Nodes.Any(a => a is CountNode))
            {
                var countsql = (command.Nodes.Where(a => a is CountNode).First() as CountNode).Value;
                if (wheresql.Length > 0)
                {
                    countsql = $"{countsql} {wheresql}";
                }
                buffer.Append($";{countsql}");
            }
            return(buffer.ToString().Trim(' '));
        }