473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Linq To Sql Delete

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
1 4956

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: shapper | last post by:
Hello, I have two tables: TagId, PostId TagId, PostId How can I delete, given a TagId, the record from Tags and all records associated with it in PostTags.
2
by: news.microsoft.com | last post by:
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...
3
by: shapper | last post by:
Hello, I have 3 tables, Tags, ArticlesTags and FilesTags, with the following columns: Tags TagID, Text ArticlesTags TagID, ArticleID FilesTags TagID, FileID
3
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
15
by: shapper | last post by:
Hello, I have two Lists: A = {ID, Name} = { (Null, John), (Null, Mary), (Null, Andrew), (Null, Peter) } B = {ID, Name} = { (1, John), (2, Robert), (3, Angela), (4, Andrew) } I want to...
2
by: Arjen | last post by:
Hi, How can I delete multiple records with Linq? On the internet I found the DeleteAll function, but this one does not exist in my library. Please help me out. Thanks!
0
by: mesut | last post by:
Hi, I'm using LINQ.. and I would like to understand if it's a bug or not in LINQ... I've a situation like: I'm reading all records via "Select" Statement and a specific select statment #1...
0
by: Big Daddy | last post by:
I am trying to do all my DB access through LINQ. For example, I am trying to delete a record from the JobQueue table. There’s a couple ways I could do this: 1. Method 1 – The disadvantage is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.