Validate object based on external factors (ie. data store uniqueness)

后端 未结 4 1017
北荒
北荒 2020-11-28 07:17

Description

My solution has these projects:

  • DAL = Modified Entity Framework
  • DTO = Data Transfer objects th
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 07:54

    The S#arp Architecture has an [DomainSignature] method identifier that used with the class level validator [HasUniqueDomainSignature] will do the work. See the sample code below:

    [HasUniqueDomainSignature]
    public class User : Entity
    {
        public User()
        {
        }
    
        public User(string login, string email) : this()
        {
            Login = login;
            Email = email;
        }
    
        [DomainSignature]
        [NotNullNotEmpty]
        public virtual string Login { get; set; }
    
        [DomainSignature]
        public virtual string Email { get; set; }
    

    }

    Take a closer look at http://www.sharparchitecture.net/

提交回复
热议问题