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);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 canSession.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…