获取PostDeleteEventListener上的主键
本文关键字:PostDeleteEventListener 获取 | 更新日期: 2023-09-27 18:20:22
如何在NHibernate的PostDeleteEventListener上获取实体的主键值?(同时考虑复合主键的情况)
不确定你是否尝试了什么但失败了。。。因为,传递的PostDeleteEvent
对象是答案:
public void OnPostDelete(PostDeleteEvent @event)
{
var id = @event.Id;
var entity = @event.Entity;
var state = @event.DeletedState;
...
如果您要查看父Event
构造函数文档(PostDeleteEvent : AbstractPostDatabaseOperationEvent
):
/// <summary> Constructs an event containing the pertinent information. </summary>
/// <param name="source">The session from which the event originated. </param>
/// <param name="entity">The entity to be invloved in the database operation. </param>
/// <param name="id">The entity id to be invloved in the database operation. </param>
/// <param name="persister">The entity's persister. </param>
protected AbstractPostDatabaseOperationEvent(
IEventSource source
, object entity
, object id
, IEntityPersister persister)