I'm creating a Web-Service WCF
that will expose methods to do CRUD operations in a database. And I have doubts on how to create the contract interface.
The Service will allow CRUD in multiple tables and will involve many complex types like Client
, Address
, Dependent
, Functionary
, etc.
I created the contract interface called IDataPersistance
and for now it looks like this:
[ServiceContract]
public interface IDataPersistance
{
[OperationContract]
bool Insert ( object value );
[OperationContract]
bool Change ( object value );
[OperationContract]
bool Delete ( object value );
// TODO: Adicione suas operações de serviço aqui
}
The problem is that to insert a Client method Insert
should receive a Client
object, to enter a Address the Insert
method should receive a object Address
, and so on.
The same also happens as Delete
method. In some cases (such as to delete a Address ) it receives a string
as a parameter and in other cases a int
.
I'm weighing in how I could create an interface (generic?) That would serve as a contract for CRUD operations involving any type.
Or in this case I can not get away and I have to create a CRUD interface for each object that will be persisted in the bank? That is, an interface for Customers CRUD, another for Dependents CRUD, etc. ?