예제 #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);
     }
 }
예제 #2
0
 public object ConvertFrom(object value, Type targetType)
 {
     if ((value != null) && (value != DBNull.Value))
     {
         return(Enum.ToObject(targetType, Convert.ToInt32(value)));
     }
     return(SharpTypeHelper.GetDefaultValue(targetType));
 }
예제 #3
0
 public void SetValue(object obj, Column col, object value)
 {
     if ((value != null) && (value != DBNull.Value))
     {
         value = Enum.ToObject(col.DataType, value);
     }
     else
     {
         value = SharpTypeHelper.GetDefaultValue(col.DataType);
     }
     col.PropertyInfo.SetValue(obj, value, null);
 }
예제 #4
0
 public void SetValue(object obj, Column col, object value)
 {
     if ((value != null) && (value != DBNull.Value))
     {
         Type enumType = col.DataType.GetGenericArguments()[0];
         value = Enum.ToObject(enumType, value);
     }
     else
     {
         value = SharpTypeHelper.GetDefaultValue(col.DataType);
     }
     col.PropertyInfo.SetValue(obj, value, null);
 }
예제 #5
0
 private void VisitSelectField(LiteField field)
 {
     if (field.FieldType == LiteFieldTypeEnum.EntityField)
     {
         if (!string.IsNullOrWhiteSpace(field.TableAlias))
         {
             this.sb.Append("[");
             this.sb.Append(field.TableAlias);
             this.sb.Append("].");
         }
         this.sb.Append("[");
         this.sb.Append(field.FieldName);
         this.sb.Append("] AS [");
         this.sb.Append(field.FieldAlias);
         this.sb.Append("]");
     }
     else if (field.FieldType == LiteFieldTypeEnum.Function)
     {
         this.sb.Append(field.FunctionName.ToString());
         this.sb.Append("(");
         if (!string.IsNullOrWhiteSpace(field.TableAlias))
         {
             this.sb.Append("[");
             this.sb.Append(field.TableAlias);
             this.sb.Append("].");
         }
         this.sb.Append("[");
         this.sb.Append(field.FieldName);
         this.sb.Append("]) AS [");
         this.sb.Append(field.FieldAlias);
         this.sb.Append("]");
     }
     else if (field.FieldType == LiteFieldTypeEnum.ConstField)
     {
         string str = SharpTypeHelper.Format(field.ConstValue);
         this.sb.Append(str);
         this.sb.Append(" AS [");
         this.sb.Append(field.FieldAlias);
         this.sb.Append("]");
     }
     else
     {
         this.sb.Append("(");
         this.VisitSubQuery(field.SubQuery);
         this.sb.Append(") AS [");
         this.sb.Append(field.FieldAlias);
         this.sb.Append("]");
     }
 }