Suppose this simple scenario: My client already has a .net application running and he / she wants to provide some functions through WCF. So he gives me an assembly spanning an open class that exposes a method of following.
OrderDetail GetOrderDetail (int orderId) // Suppose OrderDetail has {ProductId, Quantity, Amount)
Now I want some OrderDetail (Amount) members not to be serialized. According to http://msdn.microsoft.com/en-us/library/aa738737.aspx , the way to do this is with the [DataContract] and [DataMember] / [IgnoreDataMember] attributes. However, this is not an option for me, because I can not change the source code of the client. So I'm looking for a way to specify which members I want to serialize outside, outside the type definition. Something that should look like this:
[OperationContract] [IgnoreMember(typeof(OrderDetail), "Amount" )] OrderDetail QueryOrder(int orderId){ return OrderDetail.GetOrderDetail(orderId) }
Is there any way? Thanks Bernaba
, DTO , , , .
, , WCF ,
, OrderDetailDto class OrderDetail, . OrderDetailDto DataContract DataMember ( , WCF OrderDetail)
OrderDetailDto class
OrderDetail
OrderDetailDto
DataContract
DataMember
, DTO- > Client Client Objects- > DTO
, , ( , , , - ), , - DTO, ( ), , , , DTO , ( , ).
, - . , DTO, -.
-, , , .
- , (. http://msdn.microsoft.com/en-us/library/system.reflection.emit.typebuilder.aspx), , , , -.