How to store one entity class in another in specific relation between tables?
I have these relations in my data base:
I need all authors related to my 开发者_如何学Pythonbook stored in book entity class? I was trying to resolve this by using entityset but I can't use it because there is no primary key in BookAuthors table!
Any kind of help will be great! =)
LINQ-to-SQL requires a primary key in order for it to materialize entities. And since neither Books nor Authors entities know anything about each other, I think your only option is to add a PK to BookAuthors as Pleun mentioned.
This question is very similar to yours, but note the PK on the Order_Detail table: Problem with Linq2Sql Many-to-Many relationship & Inserting new objects.
精彩评论