Created
September 14, 2009 20:14
-
-
Save subdigital/186900 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using(var db = new FooDataContext()) | |
{ | |
foreach(var row in table) | |
{ | |
Car car = (from c in db.Cars | |
where c.Id = row["CAR_ID"]).SingleOrDefault(); | |
if(car == null) | |
car = new Car(); | |
car.Id = row["CAR_ID"]; | |
car.Name = row["CAR_NAME"]; | |
if(car.IsNew()) { | |
db.Cars.InsertOnSubmit(car); | |
} | |
} | |
db.SubmitChanges(); //error on the first update | |
} | |
//here is one of the SQL statements | |
UPDATE [dbo].[T_CARS] | |
SET [Name] = @p0, [update_id] = @p1, [update_ts] = @p2 | |
WHERE 0 = 1 <---- WTH is this? | |
The error I get: | |
>> System.Data.Linq.ChangeConflictException : Row not found or changed. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment