Archive

Author Archive

add attributes on properties in a generated class

April 4th, 2012 No comments

If you need to add attributes on properties in a generated class, you can do this by using following pattern.

[MetadataType(typeof(TimeFrame_Extension))]
public partial class TimeFrame { }

public class TimeFrame_Extension
{
    [XmlIgnore]
    public string From { get; set; }

    [XmlIgnore]
    public string To { get; set; }
}

source : http://ardalis.com/adding-attributes-to-generated-classes

Ad
Categories: C#, Programming Tags: