Update uses every 'not changed property' as a key

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
nlundberg
Posts: 3
Joined: Wed 07 Oct 2009 21:23

Update uses every 'not changed property' as a key

Post by nlundberg » Wed 07 Oct 2009 21:37

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 08 Oct 2009 14:44

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.

nlundberg
Posts: 3
Joined: Wed 07 Oct 2009 21:23

Post by nlundberg » Thu 15 Oct 2009 06:37

Sorry I missed that. It solved my problem. Thanks!

Post Reply