Hi!
I've got a question about the behaviour described in the two examples below.
Setup
LLBLGen PRo 3.1
Sql Server 2008
Table1
UniqueID (PK)
Value
Table2
UniqueID (PK)
Table1ID (FK)
Value
Table1 contains row
(1,"ABC")
Table2 contains rows
(1, 1, "aaa")
(2, 1, "bbb")
The following code:
Table1Entity t = new Table1Entity();
t.UniqueID = 1;
int count = t.Table2s.Count;
results in count = 2.
The following code:
Table1Entity t = new Table1Entity(1);
int countBefore = t.Table2s.Count;
t.UniqueID = 1;
int countAfter = t.Table2s.Count;
results in countBefore = 0 and countAfter = 0.
So, accessing the related entities in code snippet one loads the related entities from DB. By first accessing the related entities in code snippet two, I somehow break the expected behaviour. A 0 before is not strange since there is no primary key value to look up. But, the 0 after?
Now, is this by design, a bug or something I've done wrong when creating my model in LLBLGen Pro?
If it's by design, is there some explanation to this behaviour?
If I've done something to cause this, I'd like some hints.
Let me know if you can't reproduce the behaviour.
Thanks in advance!