I m not being able to attach a MetadataType to a auto generated class in our application. I tested setting the Order attribute in the generated class and it works fine, but if try to use another class i cannot get the attributes later.
我还尝试了建议的解决办法:here,但没有成功。
Generated class
[Table(Name = "T_MKT_Product")]
public partial class T_MKT_Product : GlobalSist.DataAccess.Base.BaseEntity
{
[Column(Storage = "_code", DbType = "varchar(20)", IsUnique = true)]
public virtual string Code
{
get { return _code; }
set
{
if (_code != value)
{
OnPropertyChanging("Code");
_code = value;
OnPropertyChanged("Code");
}
}
}
[Column(Storage = "_name", DbType = "varchar(200)")]
public virtual string Name
{
get { return _name; }
set
{
if (_name != value)
{
OnPropertyChanging("Name");
_name = value;
OnPropertyChanged("Name");
}
}
}
[Column(Storage = "_description", DbType = "varchar(200)", CanBeNull = true)]
public virtual string Description
{
get { return _description; }
set
{
if (_description != value)
{
OnPropertyChanging("Description");
_description = value;
OnPropertyChanged("Description");
}
}
}
}
然后一界定了以下课程:
[MetadataType(typeof(ProductMetaData))]
public partial class T_MKT_Product
{
}
public class ProductMetaData
{
[Display(Order = -1)]
public virtual string Code { get; set; }
[Display(Order = -2)]
public object Name { get; set; }
[Display(Order = -3)]
public object Description { get; set; }
}
帮助!