Example #1
0
 private void VisitFilterVariable(LiteVariable var)
 {
     if (var.VariableType == VariableTypeEnum.Const)
     {
         if (var.ConstValue == null)
         {
             throw new ApplicationException("Variable的ConstValue==null");
         }
         string str = SharpTypeHelper.Format(var.ConstValue);
         this.sb.Append(str);
     }
     else if (var.VariableType == VariableTypeEnum.Array)
     {
         this.sb.Append("(");
         this.sb.Append(string.Join(",", var.ConstListValue.ToArray()));
         this.sb.Append(")");
     }
     else if (var.VariableType == VariableTypeEnum.SubQuery)
     {
         this.sb.Append("(");
         this.VisitSubQuery(var.SubQuery);
         this.sb.Append(")");
     }
     else if (var.VariableType == VariableTypeEnum.Field)
     {
         this.VisitFieldVariable(var);
     }
 }
Example #2
0
        private void VisitFieldVariable(LiteVariable var)
        {
            Func <string, string> selector = null;

            if (var.IsFullTextSearch)
            {
                if (selector == null)
                {
                    selector = i => string.Format("[{0}].[{1}]", var.TableAlias, i);
                }
                this.sb.Append(string.Join(",", var.FieldNameList.Select <string, string>(selector)));
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(var.TableAlias))
                {
                    this.sb.Append(" [");
                    this.sb.Append(var.TableAlias);
                    this.sb.Append("].");
                }
                this.sb.Append("[");
                this.sb.Append(var.FieldName);
                this.sb.Append("] ");
            }
        }