How To Delete An Entity Before Submitchanges ? |
How To Delete An Entity Before Submitchanges ? |
May 28 2009, 04:28 AM
Post
#1
|
|
|
|
Hello, I have this simple code using LINQ to SQL :
Customer c = New Customer { Name = "C1", Age = 22 }; Customer c1 = New Customer { Name = "C2", Age = 20 }; ctx.Customers.InsertOnSubmit( c ) ctx.Customers.InsertOnSubmit(c1) \\now the 2 new entities are in the datacontext , i want to remove the second customer - for whatever reason like if a user discovered that he entered it by error - I want to do that before i submit changes DeleteOnSubmit will give an exception because those 2 entities are not tracked by the datacontext yet because they are new, their status is UnTracked this sound very simple but i can't find a answer for it !! Thank you Bassam This post has been edited by Bassam EG: May 28 2009, 04:30 AM |
|
|
|
Bassam EG How To Delete An Entity Before Submitchanges ? May 28 2009, 04:28 AM
JoeAlbahari The answer is to call DeleteOnSubmit. It should NO... May 28 2009, 05:36 PM
Bassam EG Hello,
indeed, it works ! , i was confused b... May 29 2009, 02:04 PM
JoeAlbahari A new object is tracked as soon as you call Insert... May 29 2009, 09:55 PM![]() ![]() |
|
Lo-Fi Version | Time is now: 22nd November 2009 - 04:14 PM |