我有一个供应商实体,其中包含
ID - int
Status - string
Name - string
CreateDate- datetime
我正在使用部分类方法为上述实体创建数据注释。如此处所述
[MetadataType(typeof(SupplierMetadata))]
public partial class Supplier
{
// Note this class has nothing in it. It's just here to add the class-level attribute.
}
public class SupplierMetadata
{
// Name the field the same as EF named the property - "FirstName" for example.
// Also, the type needs to match. Basically just redeclare it.
// Note that this is a field. I think it can be a property too, but fields definitely should work.
[HiddenInput]
public Int32 ID;
[Required]
[UIHint("StatusList")]
[Display(Name = "Status")]
public string Status;
[Required]
[Display(Name = "Supplier Name")]
public string Name;
}
HiddenInput 注释会引发错误,指出“属性‘HiddenInput’在此声明类型上无效。它仅在‘类、属性、索引器’声明上有效。”
请帮忙