【问题标题】:NHibernate Equals and GetHashCodeNHibernate 等于和 GetHashCode
【发布时间】: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'

现在我已经阅读(但未确认)这是因为我没有在我的实体中覆盖 EqualsGetHashCode。我的问题是我是否需要这样做并且我是否需要同时覆盖 Equals(Object obj)Equals(Person person) 我假设我需要从 IEquatable<Person> 继承并这样做。

【问题讨论】:

  • 你能发布完整的例外吗? (带有堆栈跟踪和内部异常)

标签: nhibernate


【解决方案1】:

好的,如果你这样做的话,IEquatable 完全不能覆盖 Equals(Person person)

【讨论】:

    猜你喜欢
    • 2011-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-17
    • 1970-01-01
    • 2020-04-19
    相关资源
    最近更新 更多