using NHibernate; using NHibernate.Persister.Entity; ISessionFactory sessionFactory = // create the session factory ISession session = sessionFactory.OpenSession(); // Get the entity persister for a given entity class IEntityPersister persister = session.GetSessionImplementation().GetEntityPersister(typeof(SampleEntity).FullName); // Use the entity persister to perform operations SampleEntity entity = new SampleEntity(); persister.Insert(entity);
using NHibernate; using NHibernate.Persister.Entity; ISessionFactory sessionFactory = // create the session factory ISession session = sessionFactory.OpenSession(); SampleEntity entity = // retrieve an entity instance // Get the entity persister for the given entity instance IEntityPersister persister = session.GetSessionImplementation().GetEntityPersister(entity, EntityMode.Poco); // Use the entity persister to perform operations persister.Delete(entity);In both examples, we use the GetEntityPersister method to obtain an implementation of the IEntityPersister interface. The first example retrieves the persister for a given entity class, while the second example retrieves the persister for a specific entity instance. Once we have obtained the persister, we can use it to perform operations such as insert, update, and delete. Overall, the NHibernate ORM library is a popular and widely-used tool for implementing object-relational mapping in .NET applications. Its IEventSource and IEntityPersister interfaces provide a flexible and extensible way to manage the persistence and retrieval of entity data.