ORMEntityOutOfSyncException immediately after fetch?

Posts   
 
    
Emmanuel
User
Posts: 167
Joined: 13-Jan-2006
# Posted on: 20-Mar-2007 22:10:12   

I've run into a problem that I can't figure out...

I retrieve an entity from a table (SQL SERVER 2000) by contructing it using the contructor that takes the primary key as a parameter (in this case an Int32). I then retrieve it from the database using DataAccessAdapter.FetchEntity().

Immediately after fetching it, I access some of the fields and get an ORMEntityOutOfSyncException exception.

If I put a breakpoint on the FetchEntity() call, I can examine the entity object's fields immediately after the fetch and instead of having values, they have this exception.

I regenerated my DAL and do a clean build and still the same results.

What's going on here?

Other info:

.NET 2.0 Sql Server 2000 C# llblgen pro 2.0.0.0 Dec 6, 2006 ORMSupportClass DLL version 2.0.0.61205 DQE.SqlServer DLL version 2.0.0.61120

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Mar-2007 08:21:54   

Please post a code snippet and the exception stack trace. Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 21-Mar-2007 11:26:44   

Be sure FetchEntity returns TRUE. I have the feeling the entity wasn't found, so you should receive false from FetchEntity as return value. Also the entity's IsNew flag should still be true, is that correct?

Frans Bouma | Lead developer LLBLGen Pro
Emmanuel
User
Posts: 167
Joined: 13-Jan-2006
# Posted on: 21-Mar-2007 18:07:10   

Posted on: 21-mrt-2007 11:26:44
Be sure FetchEntity returns TRUE. I have the feeling the entity wasn't found, so you should receive false from FetchEntity as return value.

Thanks Otis. Indeed, it was returning false. I don't know why since the PK is a single Int field and I've double-checked that it IS in the table. I did a DBREINDEX in the hopes that that would somehow fix a bad index but I got the same result.

I can retrieve other rows OK.

It must be something to do with the database index. Or a really obscure bug in LLBLGen (which I doubt very much).

Also the entity's IsNew flag should still be true, is that correct?

Yup, IsNew == true.

Emmanuel
User
Posts: 167
Joined: 13-Jan-2006
# Posted on: 21-Mar-2007 18:23:14   

Ugh. I found the problem. My fault. Two very closely named Entities with identical field names except one has more records than the other.

Sorry to have wasted your time.

(no reply required)