开发者

NHibernate Equals and GetHashCode

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜