开发者

NHibernate Equals and GetHashCode

开发者 https://www.devze.com 2023-01-11 14:39 出处:网络
Why do I need to override Equals and GetHash code in my Entities when using NHibernate? Today I got this error

Why do I need to override Equals and GetHash code in my Entities when using NHibernate? Today I got this error

System.ApplicationException : For property 'Person' expected 'Domain.Person'
of type 'Domai开发者_Python百科n.Person' but got 'PersonProxy20252a6926f841a8b45e327292fe0eae'
of type 'Domain.Person'

Now I have read(but not confirmed) that This is because I havent overridden Equals and GetHashCode in my Entity. My question is do I need to do this AND do I need override both Equals(Object obj) and Equals(Person person) I am assuming I need to inherit from IEquatable<Person> and do so.


Ok totally CANT override Equals(Person person) for IEquatable in fact if you do it breaks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号