locked
Restrict records by ownership with Dynamic Data RRS feed

  • Question

  • User-1181987665 posted

    Hi all. I would like to ask you about a problem I've not found a solution using Dynamic Data.

    In my solution I have some Vehicles, and each vehicle can be assigned to a Company. In my domain there are also many other classes and many of this are directly or indirectly correlated to the Company entity. So now I have to show only the Vehicles related to a single Company (and not all the Vehicles from all the Companies) basing my choice on the Company related to the authenticated User. This is a common scenario in applications that host services for many different customers. All the entities of the domain has an "ownership", directly (Vehicles of a Company) or indirectly through other entities (Devices mounted on Vehicles of a Company), and it is not possible to edit tables in a flat way. 

    I've not found a solution to this problem. The scaffolded entities (I'm using Entity Framework) always show all the records from its table and there is no way to achieve a different behavior.
     
    Is that a scenario not supported or am I missing something?

    Bye

    Andrea

    Wednesday, September 10, 2008 3:39 PM

All replies

  • User-330204900 posted

    Hi Andrea, have a look at this article on my blog here Part 4 - Limit Tables shown on Default page and List, Edit & Details etc. where I was limiting row by the authenticated user.

    Hope this helps [:D]

    Wednesday, September 10, 2008 5:43 PM
  • User-1181987665 posted

     Hi steve,

    Your post is interesting but does not answer to my problem. I try to explain it again:

    Think about having three entities, Company, Vehicle and Device. A Company has many Vehicles and a Vehicle has many Devices (but also Device has many Vehicles)

    Then you think logging into the system with an User of the Company with ID == 11, I have to show only Vehicles related to this Company where Vehicle.Company.ID == 11. Also I have to show only Devices related to the same company where Device.Vehicles[n].Company.ID == 11.

    The problems here are two:

    1. how to extend the query adding this criteria?
    2. how to define this query that is different for every entity?

    One solution I'm trying is to expose an entity model based on views that adds to every entity the company ID. But this is a dirty solution because I've to change my entity model for a technical problem.

    Bye

    Andrea 

    Thursday, September 11, 2008 4:29 PM
  • User-330204900 posted

    Realy sorry I meant to post this link DynamicData - Limit Data Displayed By User [:$]

    Hope this makes sense [:D]

    Thursday, September 11, 2008 5:06 PM