Search code examples
asp.netvisual-studio-2008dynamic-datafiltering

Filters on an N:M relation


It's simple. I have three tables, for example: Persons(ID, Name, etc.) Lessons(ID, ClassroomID, Description, Etc.) Person_Lesson_Link(PersonID, LessonID) The third table links the two others in an N:M relationship. A person can follow multiple lessons, and a lesson is given to multiple persons. I've created an entity model around these tables, which only shows the Perssons and Lessons tables and which links the two. I've also created a Dynamic Data website which will allow me to work with these tables, adding, editing and removing records as needed. But I still need to know a few things, in the following priority:

  1. I need to filter the Persons based on a lesson. So a filter is needed which shows the lessons.
  2. I need to add a link between a Person and a Lesson. Or edit a link, or drop a link.

So, any examples on how to do this, without having to write lots and lots of code? (Main problem: I have about 15 of these linked tables, so I need something generic.)


Solution

  • There is standard Dynamic Data field template for editing Many-To-Many relationships in .NET4.0 based on CheckListBox. Download VS2010 and grab templates from there.

    Also you can create Filter Template based on this field template for filtering Many-To-Many relationships.