I have 5 tables in my database with the following fields:
- Customer: ID (int), Name (string)
- Project: ID (int), Name (string)
- Task: ID (int), Name(string)
- Customer_Project: ID (int), CustomerID (int) ProjectID (int)
- Project_Task: ID (int), ProjectID(int), TaskID(int)
The last two tables create associations so any number of Customers can be associated with any number of Projects. Same with Projects and Tasks.
I'm trying to adhere to good MVVM standards. In my WPF control, I have already bound ListBoxes in my view to Customers, Tasks, and Projects in my ViewModel. I have a TwoWay SelectedCustomer bound property. In my model, I have objects for all of these elements and can reference them by ID, Name, etc.
What I want to do is create a list of SelectedProjects and SelectedTasks, where the user only selects a customer from the list, and then the two listboxes populate with the "associated" Projects according to Customer_Project, and likewise with Projects_Tasks.
I really don't want to hack this functionality in using a bunch of foreach loops, I figure there has got to be a slick way using Linq joins and binding to dynamic ObservableCollections.
Any ideas?