Reputation: 157
I have a poco on the service side of my application. I want to transfer this object to the client but WITHOUT some specific properties.
Is there a way to "hide" some properties when returning the result to my client?
I already tried [IgnoreDataMember] , [IgnoreProperties("xxx")] , [NonSerialized] and many other attributes without luck... Is there any way to do this?
Upvotes: 0
Views: 857
Reputation: 223237
Your WCF service must be using a DataContract
on the poco class, remove [DataMember]
attribute from the properties and that should work.
For example, below BoolValue
will not be part of the contract.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
//Not a part of contract
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
Upvotes: 1