In LINQ to SQL, is InsertOnSubmit() required when adding via a Foreign Key?
I.e. If I have code that does the following, where orders and order lines are linked in the dbml and database via a foreigh key:
Do I still need to add the order line to the context.OrderLine collection?
No, in almost all cases it is not needed if you attach (assigned to property or add to collection of entity) it to an attached object (on that was pulled from the DB). If the root object is disconnected, but all other data relates to it, you only need to insert the root object :)
Kinda cool, hey!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With