I have an EF entity that is stored in the DB (every member in the entity is saved ti the DB). I would like to ignore some of the members when passing the entity through WCF.
Specifically the problem I have is that some of the members describe a relationship with other tables that causes WCF either to pass a lot of unnecessary data, or fail.
is there a way to define a certain member as a mapped member in the EF, but NotMapped for WCF?
my solution for now is to define a shallow equivalent of the EF entity, and pass that through WCF. I don’t like this since I have to nearly duplicate most of my data structs. Is there a better way?
btw – I saw that the other direction is possible (?) by declaring the member as “NotMapped” “DataMember”. I am looking for the opposite declaration (member belongs to EF, ignored by WCF)
thanks,
You can use the [IgnoreDataMember] attribute.
Example: