I have an BookOrder
object which has an EntityRef
var to a Book
object. The objects are linked by book Id. When inserting a new BookOrder
record, a new Book
record also gets inserted into the book
table. How do I stop this, and just insert the BookOrder
record? Thanks in advance.
2 Answers
Okay, so after searching all day I was finally able find what my problem was and how to fix it at the following link.
http://aspnetking.blogspot.com/2009/03/foreign-key-issue-for-update-in-linq.html
Oh, and I'll be sure to accept this as the answer instead of the "answer" that was nothing more than someones attempt to up their reputation by providing no real help at all. Perhaps you should actually attempt to help someone if you intend to "answer" their question.

- 75
- 9
-
the link your provided is not available, can you show me another link? – onmyway133 Oct 24 '12 at 07:04
You cannot do this, as it would create an order for a book that doesn't exist.
That's why the book gets automatically created.
You should perhaps say what technology you'r using, that would make it easier to give a more accurate answer.
And you should also accept answers to your questions, it's important for your own reputation.

- 6,167
- 4
- 34
- 47
-
Okay. Using C# LINQ to SQL Classes .dbml file. Dragged two tables from a SQL Server 2008 database on the .dbml diagram thing (Don't really know what else to call it) . The table Book has a relationship with the BookOrder table via the BookId fields. This created the EntityRef propertiy in the .dbml/BookOrder object. – Jason Nov 30 '10 at 15:53