In the code below, I do the following:
use the Get function to get an object.
I modify the object.
I then start a new transaction, insert a new object, then commit the transaction.
However, I expect that on the commit, only an insert should happen, since the update occured [i]outside[/i] of the transaction.
However, it does both an update and an insert.
Why is it not working the way I'm expecting, and how do I get it to work the intended way? Thank you
var session = kernel.Get<ISessionFactory>().OpenSession(); var websiteUnlock = session.Get<KeyCodes.Entities.Reward>((uint)30); websiteUnlock.RewardName = websiteUnlock.RewardName + " ADDED";
session.BeginTransaction(); session.Save( new KeyCodes.Entities.Reward { ConsumerType = new KeyCodes.Entities.ConsumerType { Id = 10 }, ProductLine = new KeyCodes.Entities.ProductLine { Id = 38 }, RewardName = "Fake bob reward", RewardTag = "NOTREAL" }); session.Transaction.Commit(); session.Dispose();
|