Why ReferenceEquals and == operator behave different from Equals

前端 未结 3 1143
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 20:55

I have an Entity that doesn\'t override any of the equality members\\operators.
When comparing two proxies of them (I got them from the Nhibernate session)

3条回答
  •  走了就别回头了
    2021-01-19 21:10

    If ReferenceEquals returns false, you are clearly comparing two different instances.

    Equals might still be true if it's overridden, but I don't think that's where the actual problem is.

    I'd like to know how you're mapping and getting those objects, because as the docs say, you can never get two different objects of the same type representing the same row in the same session.

提交回复
热议问题