By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,979 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,979 IT Pros & Developers. It's quick & easy.

Linq To Sql Delete

P: n/a
Hello people:

First of all forgiveness for my English.
I am working with Linq to SQL, Visual Studio 2008 and SQL Server 2000.
When you delete a record and then go back to Insert (ie, insert a record
with the same primary key)
and I run SubmitChange it generates an key duplicate exception.
I am reviewing the SQL commands generated by linq, and I see that attempts
to run
first insert command, and then delete command.
I imagine that this is the problem because I expected the first run delete
and then Insert.
Any thoughts on this?
Thanks
Dec 27 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"news.microsoft.com" <si*****@hotmail.comwrote in message
news:uA**************@TK2MSFTNGP02.phx.gbl...
Hello people:

First of all forgiveness for my English.
I am working with Linq to SQL, Visual Studio 2008 and SQL Server 2000.
When you delete a record and then go back to Insert (ie, insert a record
with the same primary key)
and I run SubmitChange it generates an key duplicate exception.
I am reviewing the SQL commands generated by linq, and I see that attempts
to run
first insert command, and then delete command.
I imagine that this is the problem because I expected the first run delete
and then Insert.
Any thoughts on this?
Thanks

Either use a (different) n-tier application structure or use the Attach()
method if you need to update entries. For example you can use
myDB.Attach(myEntry, true) to attach myEntry as modified, which will
translate into the (SQL) UPDATE-command.
Dec 27 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.