1

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.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Jason
  • 75
  • 9

2 Answers2

1

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.

Jason
  • 75
  • 9
0

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.

smirkingman
  • 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