I have two tables an employee table and a project table and I am looking to bring back a count of the number of employees assigned to each project. In the employee table I have employeeIDs and projectIDs, and in the projects table I have projectID, name, department, notes, etc. I am looking to bring back the following information and display it in one single DataGrid in silverlight with the number of employees assigned to each project as a Count.
Name Department Notes Count
There are many ways to do this, but the simplest is probably to do it like this:
Alternatively, if you created a foreign key between Projects and Employees on ProjectID (if not, you should strongly consider doing so), LINQ will kindly provide even cleaner syntax:
It doesn’t get any better than that!