Hi People,
I'm struggling with check changes made to my entities, I think i may
have found a solution, but I'm still learning nhibernate and wasn't
sure if this is a big no no. My entities travel out to my application
via WCF and DTOs.
I have a method in my manager classes:
NH Session started upsteam on a per request basis.
#region Save Storage Item ...
/// <summary>
/// Save Test Entity.
/// </summary>
/// <param name="entity">The storage item to save.</param>
/// <returns>a <c>StorageItemEntity</c></returns>
[Transaction(TransactionMode.Requires)]
public TestEntity SaveStorageItem(TestEntity entity)
{
// Get Nhs current version of the entity:
TestEntity PrevEntity = _TestDao.GetById(entity.Id);
// Merge the entity back into the session as it was
disconnected from the session when it was sent over the wire.
entity = _TestDao.Merge(entity);
// Validate
if(entity.field != PrevEntity.field) { Console.Write
("Field was changed!"); }
// Save.
return _TestDao.Save(entity);
}
#endregion
NH Session disposed of.
Is getting the state from NH this way a bad move?
Thanks!
Maxus
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.