LINQ many-to-many relationships: Solution?
c#, linq, linq-to-sql, many-to-many
Solution
Found the solution myself. For automated relationships to work, both tables need primary keys (oops). Notice artworks_subjects is missing the PK symbol.
Problem
LINQ so far has been remarkably elegant, but to perform basic m2m queries it offers no solution I can imediately see. What's worse is that while it works for any other table relationship, LINQ is not giving me an association in the class structure for my m2m table. So I can do things like ``` artwork.artists.where(...) //or artist.Artworks.add(artwork) ``` but I can't do ``` artwork.artowrks_subjects.tagSubjects.where(...) //or tagSubject.artworks_subjects.add(artwork) ``` alt text http://img299.imageshack.us/img299/257/20090902122107.png Is there a common pattern for solving this limitation?