0
I have the following class CRUD
that is generic:
public abstract class CRUD
{
protected string tabela = null;
protected object classe = null;
public CRUD() {}
public virtual void insert() { //código }
public virtual void select() { //código }
}
I created another class whether it inherits from the class CRUD
:
public abstract class PessoaCRUD : CRUD
{
public PessoaCRUD()
{
tabela = "TBUsuarios";
classe = this;
}
//sobrescrita do metódo da classe pai
public void insert() { //código }
}
And I have my class Person who inherits from Pessoacrud:
public class Pessoa : PessoaCRUD
{
public string Nome { get; set; }
public int Idade { get; set; }
}
And when I need to use the class person will be something like this:
Pessoa pessoa = new Pessoa();
pessoa.Nome = "Julia";
pessoa.Idade = 23;
pessoa.Insert();
At first it’s working, but I was in doubt, I could do the class Pessoa
inherits from the class CRUD
, but if any method needed superscript it would have to be implemented in the class Pessoa
, and not wanting to pollute the class Pessoa
with methods related to CRUD
created the class PessoaCRUD
.
Is it correct to implement so? otherwise what would be a better approach, taking into account design standards?
I’ll take a look...
– MeuChapeu