Define Entity Account in dotnet

Asked

Viewed 60 times

0

Hello,

I have to define an Entity Account for a microservice of retail software. An Account can be the type:

  • Individual
  • Familia
  • Enterprise

Being the type individual is composed of the traditional fields, which represent a user:

  • Id
  • Email
  • Name
  • Address
  • Contact
  • Date of birth

The guy Familia is composed of: one or several users, each user can associate other users and so create Familias. The user who creates the Family stays as family administrator and only he can add or delete elements of the Family.

The guy Enterprise is an account that may contain one or more associated users and is created by the enterprise itself with the following fields:

  • Id
  • Name
  • Email
  • Address
  • Contact

In your understanding what is the best way to define the entities in c# (.Net Core) ?

Must separate the concept User and Account ?

I define the entity Account that represents the three types ? In this case, how do I define the Family?

I do not know if there is a standard that can help me to define efficiently the different types of Accounts.

Thank you for your attention.

1 answer

0


You can use the concept of inheritance in object orientation. As I would:

public class Account
{
    public int Id { get; set; }
    public string Email { get; set; }
    // Todos os outros atributos comuns a todas entidades
 }

public class Individual : Account
{
     public DateTime DataNascimento { get; set; }
     // Atributos específicos dessa entidade
}

public class Empresa : Account 
{
    // Atributos específicos dessa entidade
}

public class Familia
{
    public int IndividualId { get; set; }.  //Id do Administrador
    public Individual Individual { get; set; } // Administrador
    public IEnumerable<Individual> Individuals { get; set;}
}
  • Thanks for the answer! But how would represent this scheme in a database (nosql)?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.