How to specify a min but no max decimal using the range data annotation attribute?

问题:

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.我想指定价格的十进制字段必须 >= 0 但我真的不想强加最大值。

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; }

解决方案:

参考一: https://en.stackoom.com/question/E2HE
参考二: https://stackoom.com/question/E2HE
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章