Hmm... I'm doing ISession s = e.Session.SessionFactory.OpenSession()
But when I Save() it is telling me certain tables do not exist. It seems like its creating a new sqlite in-memory database... what is the proper pattern for getting the proper SessionFactory or Configuration? Thanks! On Mar 8, 4:52 pm, nicklang <[email protected]> wrote: > Oh I feel like ISession s = e.Session.GetSession(EntityMode.Poco) is > the problem - I need to open a new session, I think. > > I will post back if that is the solution. > > On Mar 8, 4:43 pm, nicklang <[email protected]> wrote: > > > > > Hi, > > > I am implementing OnPreUpdate() and am inserting a new object in there > > (for the purpose of a simple commit/rollback system). > > > When I call Save() on my original entity, I want to intercept, insert > > a new copied entity (one without IDs so that it will get INSERTED and > > not updated) - and finally, I want the original entity to NOT CHANGE. > > > I saw the veto functionality based on the return value of the > > OnPreUpdate(), but this is saving the original entity and vetoing my > > new entity - this is the OPPOSITE of what I want. > > > Any ideas of how veto the original entity and also insert the new > > entity? > > > Thanks for any ideas/help! > > > Here is the code: > > > public class AuditEventListener : IPreUpdateEventListener > > { > > public bool OnPreUpdate(PreUpdateEvent e) > > { > > object entity = e.Entity; > > Type entityType = e.Entity.GetType(); > > if (entity is IAuditableEntity) > > { > > IAuditableEntity auditableEntity = > > (IAuditableEntity)entity; > > auditableEntity.Audit = new Audit(); > > > Type copyType = typeof(IAuditableCopy<>); > > Type[] types = new Type[] { entityType }; > > Type genericCopyType = > > copyType.MakeGenericType(types); > > > if (genericCopyType.IsInstanceOfType(entity)) > > { > > MethodInfo castMethod = > > entityType.GetMethod("AuditableCopy"); > > object newEntity = castMethod.Invoke(entity, new > > object[]{}); > > > using (ISession s = > > e.Session.GetSession(EntityMode.Poco)) > > { > > s.Save(newEntity); > > s.Flush(); ///////////// NOT GETTING INSERTED > > } > > } > > } > > return true; //////// ORIGINAL ENTITY STILL GETS UPDATED > > } > > } -- 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.
