mercredi 27 octobre 2021

Create Person(Real person or Legal Person) using design pattern

I have person class :

public class Person : 
    {
     public Guid Id { get; set; }
     public Guid? PersonRealId { get; set; }
     public Guid? PersonLegalId { get; set; } 
     public virtual PersonReal PersonReal { get; set; }
     public virtual PersonLegal PersonLegal { get; set; }
    }

the real one :

 public class PersonReal 
    {
        public Guid Id { get; set; }
        public string Title { get; set; }
        public Guid Sex { get; set; }
        public string FirstName { get; set; }
    }

and the legal one has :

public class PersonLegal 
    {
        public Guid Id { get; set; }
        public string Title { get; set; }
        public string Name { get; set; }
        public Guid? TopManager { get; set; }
        public string NationalCode { get; set; }
    }

the person is always one of the real or legal type and not both of the same time . what is the best pattern to implement person using design pattern?

Aucun commentaire:

Enregistrer un commentaire