[FIXED] .Equals issues

Posts   
 
    
ctadlock avatar
ctadlock
User
Posts: 60
Joined: 12-Feb-2004
# Posted on: 17-Aug-2004 22:34:03   

Can anyone explain why the following code results in "b" being true?

Admin a = new Admin(1);

// at this point a.IsNew is true

adapter.FetchEntity(a);

// at this point a.IsNew is false

AdminRole ar = new AdminRole(1);

// at this point ar.IsNew is true

adapter.FetchEntity(ar);

// at this point ar.IsNew is false

bool b = a.Equals(ar);

From what I can tell from digging onto the code, the .Equals(object obj) method on EntityBase2 looks at the PK fields of the entity, but it never compares that the derived types are also equal, just that they both are entities.

Thanks CT

ctadlock avatar
ctadlock
User
Posts: 60
Joined: 12-Feb-2004
# Posted on: 17-Aug-2004 22:50:35   

I did some more debugging, heres what I came up with...

I added the entity comparison...

Login l = new Login(1); adapter.FetchEntity(l);

bool b2 = l.Equals(a); // false bool b3 = l.Equals(ar) // false

The reason that an "Admin" entity will Equals() an "AdminRole" entity but not a "Login" entity (all with the same PK value) is that the number of fields is the same for "Admin" and "AdminRole" but different than the number of fields for "Login".

Is this a bug, or am I missing the design principle?

CT

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 18-Aug-2004 10:33:47   

A bug. the types should be the same. Will fix it.

A hotfix for this is now available.

Frans Bouma | Lead developer LLBLGen Pro