I am rewriting the ASP.NET Identity user system with Dapper instead of Entity Framework and encountered an issue while creating new user accounts.
We have a user object passed to us by identity that is inserted to a database, however that user object does not yet have the correct Id because Identity can't know what auto-increment the database is up to yet.
So the SQL procedure that inserts the user object also returns all the data of the user that was just inserted, I'll call this returned object retUser.
In C#, if I set the user object in the following way:
user.Id = retUser.Id;
then the Id is changed correctly and the user of the website can proceed as normal.
If I instead set the entire user model in the following way:
user = retUser;
Then C# instead "assigns by value" I assume, and does not actually change the global version of the user object.
Is there a single line assignment in C# that allows me to set the entire user object by reference? Or am I misunderstanding why this is occurring?