Skip to content

Instantly share code, notes, and snippets.

@subdigital
Created September 14, 2009 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subdigital/186900 to your computer and use it in GitHub Desktop.
Save subdigital/186900 to your computer and use it in GitHub Desktop.
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