fluent-nhibernate icon indicating copy to clipboard operation
fluent-nhibernate copied to clipboard

Modify Entity.Equals to Return False When Both IDs are Zero

Open jonathanburrows opened this issue 8 years ago • 0 comments

May I request that the method Equals on the class FluentNHibernate.Data.Entity return false when both have 0 ids, since that indicates they have not been created yet, and are not equal?

The main reason I would like this is because of when intializing a class which has a hashset property:

class ChildEntity: Entity { }

class ParentEntity: Entity
{
    public ICollection<ChildEntity> MyProperty { get; set; } = new HashSet<ChildEntity>();
}

...

// Will have only one child.
var myVariable = new ParentEntity
{
    MyProperty = { new ChildEntity(), new ChildEntity() }
}

The function which would be modified can be found here.

No biggy if it shouldn't be the case though, as it's virtual. But would be nice if an additional class didn't have to be added over-top of it.

jonathanburrows avatar Jun 08 '17 03:06 jonathanburrows