Subsonic 3, MySql, won't update record.
- by Warspawn
[WebMethod]
public string GetAuthToken(string username, string password)
{
var db = new LogicDB();
//var results = from u in db.Users
// where u.Username == username && u.Password == password
// select u;
User u = db.Select
.From<User>()
.Where(UsersTable.UsernameColumn).IsEqualTo(username)
.And(UsersTable.PasswordColumn).IsEqualTo(password)
.ExecuteSingle<User>();
if (u == null)
{
return "{'success': false, 'reason': 'Invalid username and/or password.'}";
}
else
{
// really there should only be one match...
Guid code = Guid.NewGuid();
u.Securitycode = code.ToString();
u.Securityexp = System.DateTime.Now.AddHours(24);
//u.Save(db.Provider);
return "{'id':'" + u.Id.ToString() + "', 'code':'" + code.ToString() + "', 'exp':'" + u.Securityexp.ToString() + "'}" + "\n\n<br/><br/>" +
u.GetDirtyColumns().ToArray().ToString();
}
}
When I run that, I keep getting:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
This is when u.Save(db.Provider); is uncommented. And happens even with just u.Save(); or using the linq query above results instead.