/// <summary>
        ///    sample:<temp name=[模板名称]></>
        /// </summary>
        /// <returns></returns>
        internal static string BuildSql(IContext context, string oldSql, Segment segment)
        {
            var      templateName = segment.Args.ElementAt(1);
            Template template;
            var      index = templateName.LastIndexOf('/');

            if (index < 0)
            {
                template = context.GetHandlerConfig().Templates.FirstOrDefault(t => string.Equals(t.Name, templateName, StringComparison.OrdinalIgnoreCase));
            }
            else
            {
                var           config        = templateName.Substring(0, index);
                HandlerConfig handlerConfig = JsonParser.ReadHandlerConfig <HandlerConfig>(config);
                templateName = templateName.Substring(index + 1);
                template     = handlerConfig.Templates.FirstOrDefault(t => string.Equals(t.Name, templateName, StringComparison.OrdinalIgnoreCase));
            }

            var content = SegmentUtil.GetContent(oldSql, segment);

            content = SegmentUtil.BuildContent(context, oldSql, content, segment);
            var paramStrs        = content.Trim().Split(SqlKeyWorld.Split4);
            var newTemplateValue = SqlParser.GetFormatSql(context, template.Value);

            return(string.Format(newTemplateValue, paramStrs));
        }
        internal static string BuildSql(IContext context, string oldSql, Segment segment)
        {
            var    data     = ParamsUtil.GetParamData(context, segment.Args.ElementAt(0)).Data;
            var    isArray  = ReflectUtil.ReflectUtil.IsArray(data);
            string inParams = ValueGetter.Builder(data, isArray);

            if (!string.IsNullOrEmpty(inParams))
            {
                return(string.Concat(segment.Args.ElementAt(1), SqlKeyWorld.WhiteSpace, SqlKeyWorld.In, "(", inParams, ")"));
            }

            return(SegmentUtil.GetContent(oldSql, segment));
        }
        internal static string BuildSql(IContext context, string oldSql, Segment segment)
        {
            var eval   = EvalHelper.GetDelegate(context, segment.ArgContext);
            var result = (bool)eval.DynamicInvoke();

            if (!result)
            {
                return(string.Empty);
            }

            var content = SegmentUtil.GetContent(oldSql, segment);

            return(SegmentUtil.BuildContent(context, oldSql, content, segment));
        }
        internal static string BuildSql(IContext context, string oldSql, Segment segment)
        {
            var data = ParamsUtil.GetParamData(context, segment.Args.ElementAt(0)).Data;
            IEnumerable <object> datas = data as IEnumerable <object>;

            if (datas == null)
            {
                datas = data.ToString().Split(SqlKeyWorld.Split3);
            }

            var content = SegmentUtil.GetContent(oldSql, segment);

            content = SegmentUtil.BuildContent(context, oldSql, content, segment);
            var paramStrs = content.Trim().Split(SqlKeyWorld.Split4);
            var lenData   = datas.Count();
            var template  = paramStrs[0];
            var split     = string.Empty;

            if (paramStrs.Length > 1)
            {
                split = paramStrs[1];
            }

            StringBuilder sb = new StringBuilder();

            for (var i = 0; i < lenData; i++)
            {
                sb.Append(string.Format(template, datas.ElementAt(i)));
                if (i != lenData - 1)
                {
                    sb.Append(split);
                }
            }

            return(sb.ToString());
        }