I'm using the latest version (mar 2009) of LLBLGen Pro 2.6, with VS 2008 Sp1 / .Net 2.0.
The DB is access.
I'm having an issue related to fetching an entity collection with related data.
I've built a little project reproducing the issue.
There is a single table (MyEvent); in this table there is a list of "events".
The columns are:
IDEvent (key), Canceled (Boolean), IDPreviousEvent (unique, not required), IDPreviousEventForCanceledEvent(NOT unique, not required), Description
Each event can refer a single PreviousEvent. (IDPreviousEvent is unique)
Each event can be "canceled".
Each event can be referenced by multiple canceled events. (IDPreviousEventForCanceledEvent is NOT unique)
There are 2 relations:
MyEvent.IDPreviousEvent 1 ---> 1 MyEvent.IdEvent
MyEvent.IDPreviousEventForCanceledEvent m ---> 1 MyEvent.IdEvent
When I load events without a prefetch path, everything go fine (see the button "Test 1" in the attached project)
And the data looks like
IDEvent, Canceled, IDPreviousEvent, IDPreviousEventForCanceledEvent, Description
1 False Event A
2 False 1 Event B
3 False 2 Event C
4 True 3 Event D1 canceled
5 True 3 Event D2 canceled
6 True 3 Event D3 canceled
7 False 3 Event D4 ok
8 False 7 Event E
9 False 8 Event F
But when I load events with a prefetch path for loading related "Previous Event", the data and the "PreviousEventEntity" fetched get mismatched/messed-up, and the data looks like:
IDEvent, Canceled, IDPreviousEvent, IDPreviousEventForCanceledEvent, Description
1 False 2 Event A
2 False 3 Event B
3 False 7 Event C
4 True 3 Event D1 canceled
5 True 3 Event D2 canceled
6 True 3 Event D3 canceled
7 False 8 Event D4 ok
8 False 9 Event E
9 False 8 Event F
See the changed data in "IDPreviousEvent" column, these aren't the values in the DB. They get mismatched/messed-up due to prefetch path trying to load the "PreviousEntity".
I got stuck on this, and I didn't test if the others property/prefetch path (NextEvent / NextCanceledEvents / PreviosuEventForCanceledEvent) works correctly.
Another issue I've found is that the designer is a little unclear about the descriptions of relations in self-referencing table.
For the "PreviousEvent" field_on_relation it say:
Returns one instance of the entity 'MyEvent' which are directly related to the instance of the entity 'MyEvent' where MyEvent.IdpreviousEvent=MyEvent.Idevent
I believe that a clearer description could be
Returns one instance of the entity 'MyEvent (B)' which are directly related to the (current) instance of the entity 'MyEvent (A)' where MyEvent(A).IdpreviousEvent=MyEvent(B).Idevent
This will make clear:
*) which entity is the already loaded
*) which entity will be loaded/returned
*) how the loaded data will be used to build the filter to fetch the returned entity