Row not found or changed

Row not found or changed

Postby jonsidnell » Mon 14 Dec 2009 12:31

Hi

I'm using dotConnect for MySQL, and Entity Developer to create a Linq to MySQL data model to use in an ASP.NET MVC project. The model is as below:

Image

The bit I'm developing at the moment is the user registration process. I'm using the Repository pattern as recommended by people like Scott Guthrie and Steve Sanderson. I've managed to successfully create a user record with the following code:

Code: Select all
// 1. Encrypt password
user.Password = EncryptPassword(user.Password);

// 2. Generate GUID for verify code
user.VerificationGuid = System.Guid.NewGuid();

// 3. Set user level
user.UserType = userRepo.SetUserType(user.UserType.AccessLevelId);

// 4. Set sign up date
user.SignupDate = DateTime.Now;

// 5. Set some defaults for cross-compatibility with old code
user.SetDefaults();

// 6. Add to database
userRepo.Add(user);
userRepo.Save();

// 7. Send email to user
user.SendVerificationEmail();


I'm then getting problems with the activation of this user record, which uses the following code:

Code: Select all
User user = userRepo.GetUserForActivation(verify, email);

if (user == null)
    return View("ActivationError");

// Update user's active status
user.Active = true;

// Persist
userRepo.Save();


dataContext.SubmitChanges() is raising a Devart.Data.Linq.ChangeConflictException, with a message of "Row not found or changed." but drilling down further to cycle through the collection of MemberConflicts doesn't yield any specific conflicts.

Any help that can be provided would be extremely welcome - I'm close to tearing my hair out here!

Thanks
Jon[/img]
jonsidnell
 
Posts: 5
Joined: Mon 14 Dec 2009 12:06

Postby AndreyR » Mon 14 Dec 2009 14:17

Could you please send me (support * devart * com, subject "LINQ: Row not found or changed")
a small test project illustrating the error?
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby jonsidnell » Mon 14 Dec 2009 15:14

Hi Andrey,

I've worked out what's been going wrong - I changed the Nullable property on some string fields, and hadn't ensured they were granted a value other than null in the database.

This resulted in SQL being generated that was testing for " = NULL" rather than IS NULL, which meant that the WHERE clause of the UPDATE statement wasn't ever resolving to a row.

I've amended what I'm doing in the code, and it all works as intended now.

Thanks
Jon
jonsidnell
 
Posts: 5
Joined: Mon 14 Dec 2009 12:06


Return to LinqConnect (LINQ to SQL support)