Is it possible to add an attribute to a property in a partial class?

前端 未结 4 598
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 00:53

I don\'t think it\'s possible but since I haven\'t got a definite clarity from MSDN, I feel that it\'s best to ask. Suppose that we have a class as follows.

         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 01:52

    of course you can do it using Metadata as follow:

    public partial class Hazaa : EntityBase
    {
        public int Shazoo { get; set; }
    }
    
    [MetadataTypeAttribute(typeof(HazaaMetadata))]
    public partial class Hazaa : EntityBase
    {
        internal sealed class HazaaMetadata
        {
            [SuperCool]
            public int Shazoo { get; set; }
        }
    }
    

提交回复
热议问题