如何指定分钟,但使用的范围数据注解属性没有最大小数? [英] How to specify a min but no max decimal using the range data annotation attribute?
本文介绍了如何指定分钟,但使用的范围数据注解属性没有最大小数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想指定的十进制领域的价格必须> = 0,但是我真的不希望强加最大值。
下面是我到目前为止...我不知道该怎么做这种正确的做法是。
[范围(typeof运算(十进制),0, - ]公共十进制价格{获取;集;}
解决方案
哦,好像没有选择,只能把在最大值手动。我希望有一些类型的过载,你并不需要指定一个。
[范围(typeof运算(十进制),0,79228162514264337593543950335)
]公共十进制价格{获得;组; }
I would like to specify that a decimal field for a price must be >= 0 but I don't really want to impose a max value.
Here's what I have so far...I'm not sure what the correct way to do this is.
[Range(typeof(decimal), "0", "??"] public decimal Price { get; set; }
解决方案
Oh well, it seems there's no choice but to put in the max value manually. I was hoping there was some type of overload where you didn't need to specify one.
[Range(typeof(decimal), "0", "79228162514264337593543950335")
] public decimal Price { get; set; }
这篇关于如何指定分钟,但使用的范围数据注解属性没有最大小数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文