Description:
I used the Business Application Template to create my application. using MySQLConnector .NET v6.3.5.
1. My User class:
public partial class User : UserBase
{
[ProfileUsage(IsExcluded = true)]
public Int32 UserID { get; set; }
public string FriendlyName { get; set; }
public string RTrackLineColor { get; set; }
}
2. Web.config
<profile enabled="true" defaultProvider="MySQLProfileProvider"> <properties> <add name="FriendlyName" /> <add name="RTrackLineColor" type="string" defaultValue="Green" /> </properties>
<profile enabled="true" defaultProvider="MySQLProfileProvider">
<properties>
<add name="FriendlyName" />
<add name="RTrackLineColor" type="string" defaultValue="Green" />
</properties>
3. Setting the property and saving:
WebContext.Current.User.RTrackLineColor = "value";
WebContext.Current.Authentication.SaveUser(false);
Each time after saving, then log off and log in, the WebContext.Current.User.RTrackLineColor won't take the latest value set for the property but the first value set instead.
How to repeat:
This is my reported bug with RIA but it seems not the bug of RIA.
http://forums.silverlight.net/forums/t/219559.aspx
Suggested fix:
I user Red Gate Reflector to look into the MySql.Web.dll and found out here could have been causing the problem.
public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
{
...............
Should check the for Inserting or updating existing value for the index (profile property) here.
...............
MySqlCommand command = new MySqlCommand("INSERT INTO my_aspnet_Profiles \r\n VALUES (@userId, @index, @stringData, @binaryData, NULL) ON DUPLICATE KEY UPDATE\r\n valueindex=VALUES(valueindex), stringdata=VALUES(stringdata),\r\n binarydata=VALUES(binarydata)", connection);
command.Parameters.Clear();
command.Parameters.AddWithValue("@userId", num2);
command.Parameters.AddWithValue("@index", index);
command.Parameters.AddWithValue("@stringData", stringData);
command.Parameters.AddWithValue("@binaryData", binaryData);
if (command.ExecuteNonQuery() == 0)
{
throw new Exception(Resources.ProfileUpdateFailed);
}
transaction.Commit();
}
catch (Exception exception)
{
if (transaction != null)
{
transaction.Rollback();
}
throw new ProviderException(Resources.ProfileUpdateFailed, exception);
}
finally
{
if (connection != null)
{
connection.Dispose();
}
}
}
}
}
..........
}