public virtual void Visiting(SqlNumericLiteral numericLiteral) { sqlBuilder.Append(EncapsulateNumeric(FormatNumeric(numericLiteral.DecimalValue))); }
private SqlExpression EvalDecimalValue(NPathDecimalValue value) { SqlNumericLiteral numericLiteral = new SqlNumericLiteral((Decimal)value.Value) ; return numericLiteral; // string paramName = GetParameterName(); // IQueryParameter param = new QueryParameter(paramName, DbType.Decimal, value.Value ) ; // ResultParameters.Add(param); // SqlParameter sqlParam = select.AddSqlParameter(paramName, DbType.Decimal, value.Value) ; // return sqlParam ; }
public virtual void Visited(SqlNumericLiteral numericLiteral) { }
private SqlExpression EvalCompareExpression(NPathCompareExpression compareExpression) { SqlSearchCondition search ; if (noNext) search = conditionChainOwner as SqlSearchCondition ; else search = conditionChainOwner.GetNextSqlSearchCondition() ; noNext = false; SqlExpression leftExpression = null; SqlExpression rightExpression = null; if (compareExpression.RightOperand is NPathIdentifier && !IsEnum(compareExpression.RightOperand) && IsEnum(compareExpression.LeftOperand)) { //left operand is enum rightExpression = EvalExpression(compareExpression.RightOperand); NPathIdentifier propertyPath = (NPathIdentifier)compareExpression.RightOperand; NPathIdentifier enumIdentifier = (NPathIdentifier)compareExpression.LeftOperand; Type enumType = GetTypFromPropertyPath(propertyPath); if (!enumType.IsEnum) throw new Exception(string.Format("Property '{0}' is not an Enum type",propertyPath.Path)); int enumValue = GetEnumValue(enumType,enumIdentifier.Path); leftExpression = new SqlNumericLiteral(enumValue); } if (compareExpression.LeftOperand is NPathIdentifier && !IsEnum(compareExpression.LeftOperand) && IsEnum(compareExpression.RightOperand)) { leftExpression = EvalExpression(compareExpression.LeftOperand); NPathIdentifier propertyPath = (NPathIdentifier)compareExpression.LeftOperand; NPathIdentifier enumIdentifier = (NPathIdentifier)compareExpression.RightOperand; Type enumType = GetTypFromPropertyPath(propertyPath); if (!enumType.IsEnum) throw new Exception(string.Format("Property '{0}' is not an Enum type",propertyPath.Path)); int enumValue = GetEnumValue(enumType,enumIdentifier.Path); rightExpression = new SqlNumericLiteral(enumValue); } else { leftExpression = EvalExpression(compareExpression.LeftOperand); rightExpression = EvalExpression(compareExpression.RightOperand); } SqlPredicate predicate; if (compareExpression.RightOperand is NPathNullValue) { if (compareExpression.Operator == "=") predicate = search.GetSqlIsNullPredicate(leftExpression); else if (compareExpression.Operator == "!=") // do not localize predicate = search.GetSqlIsNullPredicate(leftExpression, true); else throw new NPathException("Comparisment operand " + compareExpression.Operator + " can't be used for comparisment with Null value!"); // do not localize } else { predicate = search.GetSqlComparePredicate(leftExpression, EvalOperator(compareExpression.Operator) ,rightExpression) ; } return predicate; }