Using NHibernate, is it possible to fill an existing object using the results of a query, rather than returning a new entity? For example:
var foo = new Foo();
session.GetById(foo, id);
Using NHibernate, is it possible to fill an existing object using the results of a query, rather than returning a new entity? For example:
var foo = new Foo();
session.GetById(foo, id);
Well... kind of... If you object is transient you can Session.Get<Foo>(id)
another object into NH identity map and then manually copy its fields into your object. If your object is persistent (attached to a session), you can Session.Refresh(foo)
to re-retrieve it from DB.
I guess you can try doing Session.Lock on your transient instance to reattach it to the session and then Session.Refresh to refresh it... Should work... at least in theory...