0
我在MSDN中找到了follwing代碼。我如何使用我的Product類具有的值更改此「UnitsInStock」。例如,Product有一個FieldType屬性,它有一個名爲Name的字符串屬性。我想使用FieldType.Name屬性而不是使用字符串硬編碼。但是,我無法將「this」或當前實例指定爲UIHint屬性的參數。請幫助UIHint屬性可以接受當前類的屬性嗎?
using System;
using System.Web.DynamicData;
using System.ComponentModel.DataAnnotations;
[MetadataType(typeof(ProductMetadata))]
public partial class Product
{
}
public partial class ProductMetadata
{
[UIHint("UnitsInStock")]
[Range(100, 10000,
ErrorMessage = "Units in stock should be between {1} and {2}.")]
public object UnitsInStock;
}