Page 1 of 1

Update uses every 'not changed property' as a key

Posted: Wed 07 Oct 2009 21:37
by nlundberg
Hi,

When performing an update of an item and only few of the item's properties have changed then all not changed properties are used as keys in the update statement generated by Linq To Sql.

I'm using the latest version released (2009-10-07) of dotConnect for MySQL.

Here is an pseudo code example. Only relevant code is presented.


//old password == "myoldPw"
_password = "myNewPassword;


var data = (from user in dataContext.Users where user.UserId == id select item).Single();

data.UserId = _userId
data.Username = _username;
data.Email = _email;
data.IsUnlocked = _isUnlocked;
data.Created =_created;
data.Password = _password

dataContext.SubmitChanges();

The sql statement generated is:

UPDATE user SET Password = :p1 WHERE UserId = :key1 AND Username = :key2 AND Email = :key3 AND IsUnlocked...


Thanks
Niklas

Posted: Thu 08 Oct 2009 14:44
by AndreyR
Please set Update Check to WhenChange (or to Never) in Entity Developer to change this behaviour.
The Update Check property is set to Always by default, like in Microsoft LINQ to SQL.

Posted: Thu 15 Oct 2009 06:37
by nlundberg
Sorry I missed that. It solved my problem. Thanks!