I have a strange behavior when I populate my own typed session with session.PopulateWithNonDefaultValues(userModel)". I get the old session back when I use SessionAs but everything works fine if I simply assigne the new values with session.FirstName = "MyVal"
var session = SessionAs<MySession>();
session.PopulateWithNonDefaultValues(userModel);
// works fine if I do:
// session.FirstName = "MyVal";
this.SaveSession(session);
var session2 = SessionAs<MySession>();
Seems like a reference issue to me - I would like to use some kind of populating instead of assigning all properties by hand.
public class MySession: AuthUserSession {}
public class MyModel : UserAuth {}
Both instances looks absolutely the same after populating e.g. if I output to JSON or set a breakpoint at this.SaveSession(session) - but this.SaveSession(session); seems not to save the session or SessionAs do something different. Sorry, maybe it helps - I forgot to say that I’m using Reids as CacheClient.
Something seems wrong, are you saying that if you manually populate the property with:
session.FirstName = "MyVal";
And Save and retrieve the session it works, but if you use PopulateWithNonDefaultValues() the property is still populated but it no longer saves the property? can you confirm this in a debugger because that sounds wrong, it shouldn’t matter how the property is populated.
now sessionToCheck.FirstName is null. It doesn’t even matter where I put PopulateWithNonDefaultValues at. If I do a call to the method SessionAs returns the old data.
The only one difference is: session.PopulateWithNonDefaultValues(userEntity);
Omg, thats it - thats why it looks equal. Didn’t recognized because Id seems the be correct (User.Id == Session.Id). Confirm also in Redis - UserId was used as SessionId.