As per title. Using native ID's
The only thing I can think to do is to call GetByExample(entityJustInserted)开发者_开发技巧 and pick the one with the highest ID. Not great...anyone got a better way?
Thanks.
You can get it directly off of the entity you just inserted:
For example:
entityRepository.Save(entity);
return entity.Id;
NHibernate will automatically populate the property with the generated id.
精彩评论