开发者

ASP.NET MVC3 Metadata problem on class named as .NET keyword

I've a problem when adding metadata to a class named as a reserved keyword. During the generation of the data model (the DBML file), an @ has been added to the class name to have it working.

When I apply metadata to the class, it is not working (metadata info is not taken in consideration - the DisplayName and other validation stuff). For all other classe开发者_StackOverflow中文版s of my project (that do not have a class name as a reserved keyword, it is working). It is currently not possible to rename that class.

Generated class definition:

[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.operators")]
public partial class @operator : INotifyPropertyChanging, INotifyPropertyChanged
{...}

MetaData class definition:

[MetadataType(typeof(OperatorMetaData))]
public partial class @operator
{
}

public class OperatorMetaData
{
    [DisplayName("Operator Type")]
    [Required(ErrorMessage = "Operator type is required.")]
    public int operator_type_id { get; set; }
    ...
}

Anyone any idea how to work around this? Or what did I do wrong ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜