O'Reilly logo

Learning NHibernate 4 by Suhas Chatekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Entity equality

In .NET, two objects are supposed to be equal when they both point to the same object in memory. This is also called reference equality. This is what the Equals method on System.Object implements. Reference equality works for normal .NET objects but is not adequate for persistent entities. Two persistent entities can be said to be equal if they point to the same database record. So if you have loaded two instances of same employee record then they are not equal on reference equality measures, but for NHibernate they are equal.

Why does equality matter?

Equality obviously matters if you want to compare two entities. But beyond the basics, equality matters because some basic collection operations depend on equality of objects. Calling ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required