vendredi 13 mars 2015

Passing data from client to wcf service to domain layer

I want a consumer app to send some data structure to a wcf service, then this service pass the data to the business model objects.


What I would like is to avoid the need to copy manually each property of the service data object to a new business object.


For example:



[DataContract]
public class MyServiceData
{
[DataMember]
public Property1() { get; set;}
[DataMember]
public Property2() { get; set;}
[DataMember]
public Property3() { get; set;}
}

public class MyWcfService : IMyWcfService
{
public void Operation1(MyServiceData data)
{
var obj = new DomainObject();
obj.Property1 = data.Property1;
obj.Property2 = data.Property2;
obj.Property3 = data.Property3;

obj.DoSomething();
}
}


I could put MyServiceData class in the business object layer, but I don't think it is a good thing to use these wcf service attributes in a business model object.


Is there any design pattern I could use to achieve this ?


Aucun commentaire:

Enregistrer un commentaire