1

有人可以举一个例子来说明 Ayende 在他的不编写自己的对象关系映射器的 25 个理由列表中的第 17 项中所说的内容吗

这是 ADO.NET Entity Framework 可以做到的吗?

4

2 回答 2

1

想象一个 AD 支持的成员模型,它也在 SQL 中存储信息。创建用户时,您可能希望能够在 AD 和 SQL 中创建用户。生命周期事件让您有机会拦截某些事件,如 Create Update 等。以允许您做某事。

于 2009-04-22T12:18:50.940 回答
0

NHibernate has an event system, where you get events (actually callbacks) when NHibernate is doing something with your entity. The call backs could be registered on the session or just implemented in the entity using an interface.

There are many examples of the usage of such a callback, and it could be vital for a project. Many people are writing audit logs using these callbacks. Or just updating some properties that are not stored in the database. Ayende probably means that with "fetching data from other locations as well".

I don't know if the entity framework has life cycle callbacks. NHibernate is very very very extensible and you can hook you custom code in to nearly every part. Generally I doubt that entity framework is that extensible.

于 2009-04-22T12:42:40.773 回答