Home > C#, Programming > add attributes on properties in a generated class

add attributes on properties in a generated class

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:
  1. No comments yet.
  1. No trackbacks yet.
*