【发布时间】:2010-08-16 16:14:38
【问题描述】:
为什么在使用 NHibernate 时需要覆盖我的实体中的 Equals 和 GetHash 代码?今天我收到了这个错误
System.ApplicationException : For property 'Person' expected 'Domain.Person'
of type 'Domain.Person' but got 'PersonProxy20252a6926f841a8b45e327292fe0eae'
of type 'Domain.Person'
现在我已经阅读(但未确认)这是因为我没有在我的实体中覆盖 Equals 和 GetHashCode。我的问题是我是否需要这样做并且我是否需要同时覆盖 Equals(Object obj) 和 Equals(Person person) 我假设我需要从 IEquatable<Person> 继承并这样做。
【问题讨论】:
-
你能发布完整的例外吗? (带有堆栈跟踪和内部异常)
标签: nhibernate