In my database I want to save the user GUI settings for one of the “views”, as a semicolon-separated string, i.e. : “1;31;5;411;”.
I use NNibernate for this project, and this is the mapping and the code for this specific private member;
C# entity code for User.Settings
private string _linkConsole = "0";
[DataMember]
public LinkConsole LinkConsole
{
get { return new LinkConsole(_linkConsole); }
set { _linkConsole = value.GetSqlString(); }
}
XML mapping:
<property name="LinkConsole" type="System.String" access="field.camelcase-underscore" not-null="true"/>
LinkConsole has a lot of public methods for GUI-specific settings, which is toggling the values of certain private members.
When its time to save this settings to the database, .GetSqlString(); formats the string and writes it to the private member _linkConsole , which is the private member exposed to NHibernate & the database.
Problem:
When I try to do something with the GUI, i.e.:
User.Settings.LinkConsole.SetRightPaneContent(50);
This is never stored on the object LinkConsole, and I can’t seem to figure out why?
When I set a breakpoint, I get a message in Visual Studio stating:
Your step-into request resulted in an automatic step-over of a property or operator
Maybe this is a result of the problem, that I’m designing this in a wrong way?
If so, is it possible to achieve this in combination with a private string member?
Any help would be greatly appreciated! Thanks! 🙂
This isn’t really an
NHibernateissue.LinkConsoleis a reference type. If you set a member of it, it isn’t going to call thesetmethod on the property you got it from, it’s going to set the value on the instance that was returned from the originalget. If you want this code to work, you’d need to get a newLinkConsoleinstance from theUser, call the methods to set the settings, then set theLinkConsoleproperty of the user to your configured instance.