I have the following code:
Guid id = imageMetaData.ID;
Data.LinqToSQL.Image dbImage = DBContext.Images.Where(x => x.ID == id).SingleOrDefault();
dbImage.width = imageMetaData.Width;
dbImage.height = imageMetaData.Height;
DBContext.SubmitChanges();
Looking at SQL Profiler, the following SQL is being generated:
exec sp_executesql N'UPDATE [dbo].[Images]
SET [height] = @p0, [width] = @p1
WHERE 0 = 1',N'@p0 int,@p1 int',@p0=603,@p1=365
Why does my where statement not include a "where id=...."???
What am I doing wrong?
My application throws a ChangeConflictException with the message... "Row not found or changed"
Check to make sure your model matches the DB. I've run across this if they are out of sync, in most cases the nullable flag. Check out this article for a possible cause.
I assume you are using the release version of .net 3.5 (Visual Studio 2008).
Found the solution in: http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/c672c8ee-bf2a-41b4-bb8b-aa76cc5d9b95 (posted by Todd Fleenor)
The problem can be solved this error by redragging the table from the server explorer to the designer and rebuilding. So the designer was out-of-synch with the SQL Table...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With