Take the 2-minute tour ×

I'm new to WCF. My web project has an ADO.NET Entity Data Model (aka EF edmx), which has the Entity Container Name "JobSystemEntities".

I've created a simple oData WCF data service which uses JobSystemEntities, and it works great:

public class JobService : DataService<JobSystemEntities>
    public static void InitializeService(DataServiceConfiguration config)
        config.SetEntitySetAccessRule("Jobs", EntitySetRights.ReadSingle);

However, this exposes all of the properties on the Job. I would like to hide sensitive data, i.e. the Cost field/property/column of the Job table.

share|improve this question
The easiest would be to just hide that attribute in your EF model - e.g. not ever use/show that. Could you do this? Or could you create a custom EF model just for your OData service, and hide that attribute from the "Jobs" entity in that custom model? –  marc_s Jan 25 '11 at 10:20
I use the Cost field in the website so it needs to be in the EF model. Your suggestion to create a second EF model for the oData service is possible, but I'm surprised there isn't another way to do this? –  Matt Frear Jan 25 '11 at 10:38

2 Answers 2

I am posting this a but late, but it might help others.

You can use the IgnoreProperties attribute http://msdn.microsoft.com/en-us/library/system.data.services.ignorepropertiesattribute.aspx on your class.

You will have to define a partial Job class in order to do this. Something in the lines of:

namespace DAL.Entities
    public partial class Job

share|improve this answer
I don't think this works with Entity Framework as your data layer. If you have something else then it should work fine. –  Vaccano Jul 25 '11 at 20:25
I used it my self in a project recently, it worked fine with Entity Framework. –  magnuskragelund Aug 4 '11 at 19:34
When it did not work for me I asked this question: stackoverflow.com/questions/6600037/… The upshot was that it does not work for the POCO template. (Maybe it does work for normal EF though.) –  Vaccano Aug 4 '11 at 20:10

I've done something similar to this. A good starting point is found here:


Basically you will need to separate the protected properties of an entity into a separate entity that is linked as a property of the other. Once that is done user a Query Interceptor to restrict when that protected entity can be viewed.

public Expression<Func<YourObjectsProtectedProperties, bool>> OnReadYourObjectsProtectedProperties()
if (ShowEntityToUser())
   return o => true == true;
return o => true == false;
share|improve this answer

Your Answer


