I have following schema:
Clients – ClientId
Users – UserId
Offices – OfficeId
ClientOffices – ClientId, OfficeId
UserOffices – UserId, OfficeId
Bold entities are EntityFramework Entities.
Now I need to write a function which accepts UserId and returns a list of Clients – who also belong to the offices to which user belongs.
E.g., Say ABC Inc. works with London Office, XYZ Inc. works with New York office.
User “Yakoon” works only for Lond Office.
The linq statement when executed should only return ABC Inc.
If “Yakoon” belongs to New York office as well, then it should return btoh ABC and XYZ Inc.
Thanks
The entity framework equivalent approach would be something like:
Make sure you have primary keys on your UserOffices and ClientOffices tables so EF will recognize them as junction tables.