I have some classes that will use a write method. I created a CRUD (Generic) class where I would have a write method, but I need this method to take classes as a parameter.
There is some way to create a generic method for what I have read, but I was unable to pass one type of parameter that caters to all classes.
For example, this same method will write the company, contact, client in the bank, being the add function of EF.
Below is a method that I created, but it only serves the Enterprise class in this case.
public void Gravar<T>(Empresa obj)
{
context.Empresa.Add(obj);
}
How do you make it work for the Contact, Client, User, etc. class instead of Company? The way it is I would have to create a record () for each class.