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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章