Reputation: 5175
I'm using ASP.NET MVC4 (EF Code-first) with WCF ADO.NET Data Service October 2011 CTP. I have an issue - I don't know how to ignore sensitive properties (like email).
I tried using an ADO.NET Entity Data Model (.edmx) and find the declaration of the sensitive property:
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public global::System.String MySensitiveProperty
{
get
{
return _MySensitiveProperty;
}
and changing the getter:
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public global::System.String MySensitiveProperty
{
get
{
return "No data here!";
}
Is there any better and simpler solution for my issue?
Upvotes: 1
Views: 2246
Reputation: 2352
You can use the IgnoreProperties attribute. Simply decorate your class with this attribute and pass a list of property names to it. These properties will not be exposed to the data service. See here
Upvotes: 2
Reputation: 364279
In such case why do you expose that property? Once you do it this way you say that your application (no part of your application) never needs email property. In such case delete the property from entity mapped in EDMX and it will be never accessible.
Upvotes: 1