Ejemplo n.º 1
0
        public TableColumn VisitDecimal(TempTableBuilderCtx arg, bool?isNull, DecimalPrecisionScale?decimalPrecisionScale)
        {
            var column = EnsureColumnType <NullableDecimalTableColumn>(arg);

            if (ReferenceEquals(column, null))
            {
                return(CreateColumn(decimalPrecisionScale));
            }
            else
            {
                if (decimalPrecisionScale.HasValue)
                {
                    if (column.PrecisionScale.HasValue)
                    {
                        var old   = column.PrecisionScale.Value;
                        var newPs = decimalPrecisionScale.Value;

                        if (old.Precision < newPs.Precision || old.Scale < newPs.Scale)
                        {
                            return(CreateColumn(decimalPrecisionScale));
                        }
                    }
                }

                return(column);
            }

            NullableDecimalTableColumn CreateColumn(DecimalPrecisionScale?precisionScale)
            {
                return(new NullableDecimalTableColumn(this.Alias, arg.ColumnName, this, precisionScale, arg.PrimaryKey ? ColumnMeta.PrimaryKey() : null));
            }
        }
Ejemplo n.º 2
0
        protected DecimalTableColumn CreateDecimalColumn(string name, DecimalPrecisionScale?decimalPrecisionScale = null, ColumnMeta?columnMeta = null)
        {
            var result = new DecimalTableColumn(this.Alias, new ExprColumnName(name), this, decimalPrecisionScale, columnMeta);

            this._columns.Add(result);
            return(result);
        }
Ejemplo n.º 3
0
        public TRes VisitExprDecimalLiteral(ExprDecimalLiteral decimalLiteral, ExprValueTypeAnalyzerCtx <TRes, TCtx> ctx)
        {
            DecimalPrecisionScale?precisionScale = null;

            if (decimalLiteral.Value.HasValue)
            {
                SqlDecimal sd = decimalLiteral.Value.Value;
                precisionScale = new DecimalPrecisionScale(sd.Precision, sd.Scale);
            }

            return(ctx.ValueVisitor.VisitDecimal(ctx.Ctx, !decimalLiteral.Value.HasValue, precisionScale));
        }
Ejemplo n.º 4
0
 public static ExprTypeDecimal WithPrecisionScale(this ExprTypeDecimal original, DecimalPrecisionScale?newPrecisionScale)
 => new ExprTypeDecimal(precisionScale: newPrecisionScale);
Ejemplo n.º 5
0
 void VisitPlainProperty(string name, DecimalPrecisionScale?value, TCtx ctx)
 {
     this._visitor.VisitPlainProperty(name + '.' + nameof(DecimalPrecisionScale.Precision), value?.Precision, ctx);
     this._visitor.VisitPlainProperty(name + '.' + nameof(DecimalPrecisionScale.Scale), value?.Scale, ctx);
 }
Ejemplo n.º 6
0
 internal NullableDecimalTableColumn(IExprColumnSource?source, ExprColumnName columnName, ExprTable table, DecimalPrecisionScale?precisionScale, ColumnMeta?columnMeta) : base(source, columnName, table, SqQueryBuilder.SqlType.Decimal(precisionScale), true, columnMeta)
 {
     this.PrecisionScale = precisionScale;
 }
Ejemplo n.º 7
0
 public ExprTypeDecimal(DecimalPrecisionScale?precisionScale)
 {
     this.PrecisionScale = precisionScale;
 }
 public static ExprCast LiteralCast(decimal value, DecimalPrecisionScale?precisionScale = null) => Cast(Literal(value), SqlType.Decimal(precisionScale));
Ejemplo n.º 9
0
 public ExprTypeDecimal Decimal(DecimalPrecisionScale?precisionScale = null) => new ExprTypeDecimal(precisionScale);
 public bool?VisitDecimal(object?arg, bool?isNull, DecimalPrecisionScale?decimalPrecisionScale)
 {
     return(isNull);
 }
Ejemplo n.º 11
0
 public ExprValueTypeDetails VisitDecimal(object?arg, bool?isNull, DecimalPrecisionScale?decimalPrecisionScale)
 {
     return(new ExprValueTypeDetails(isNull, SqQueryBuilder.SqlType.Decimal(decimalPrecisionScale)));
 }