Take the 2-minute tour ×

I have a c# datacontext (dbml) that currently has a single table in it for a proof of concept..

What I want to do is expose this table to my web application but have the data pre-filtered using .net membership security groups/roles..

I'm exposing the tables to a reporting tool and want to just have a "clean" list of tables that return only the data the user is allowed to see..

I managed to get a "dirty" list with: Customer, CustomerFiltered using this:

public int CompanyID { get; set; }

public IQueryable<Customer> CustomerFiltered
        if (CompanyID == 0)
            return this.GetTable<Customer>().Where(c => c.CompID == -1);
            return this.GetTable<Customer>().Where(c => c.CompID == CompanyID);

But this means that there is nothing stopping the user from selecting the unfiltered "customer" table, rather than the filtered one that I want them to use..

So then I started having a look in the VS dbml designer and found an "Access" property for the Customer table. I set this to "Internal" thinking that I could then expose the table some way, so that the unfiltered "Customer" table would be hidden and I could just have a prefixed table name like "II_Customer" table that was filtered seamlessly shown to the user and they'd be none-the-wiser...

Does this make sense...??? Any help would be greatly appreciated...


share|improve this question
You'll just have to make the backing Customer table be a private field. –  jcolebrand Jan 10 '13 at 22:52
I tried that, but how do I expose that customer table publicly...??? I keep getting an error like "Inconsistent accessibility: property type 'System.Linq.IQueryable<DataAccess.Customer>' is less accessible than property 'DataAccess.DataClassesDataContext.CustomerFiltered'" –  Ads Jan 10 '13 at 22:54
I tried "public IQueryable<Customer> CustomerFiltered" –  Ads Jan 10 '13 at 22:56
try this: public IQueryable<Customer> CustomerFiltered { internal get; set; } –  jcolebrand Jan 10 '13 at 22:58
Are you trying to use it from outside the library where you declared it? (there really isn't any way in C# to stop people from using your class, you can only make it inconvenient) –  jcolebrand Jan 10 '13 at 23:04

Your Answer



Browse other questions tagged or ask your own question.