Duplicates with prefetch paths

Posts   
 
    
hardcodet
User
Posts: 6
Joined: 01-Oct-2011
# Posted on: 31-Oct-2011 15:15:12   

Hi all

I'm evaluating LLBLGen and stumbled over what looks like a bug with this simple query that contains a prefetch path. I simplified it a little in order to give you an easy repro.

Bascially, we have a 1:n relationship between a JobFunctionGroup and its contained job functions. What I did is for a set of functions, i would like to prefetch the group and also populate the group's JobFunctions collection immediately.

This hits the DB with 3 queries that eventually resolve all the job functions. However, the JobFunctions collection of the group contains the first element twice:


LinqMetaData md = new LinqMetaData(adapter);

//get all functions in the group "binning"
var functions = from f in md.JobFunction where f.JobFunctionGroup.Description.Contains("Bin") select f;

//for each function, get the group and also all the group's functions
functions = functions.WithPath(p => p.Prefetch<JobFunctionGroupEntity>(jf => jf.JobFunctionGroup)
                        .SubPath(p2 => p2.Prefetch(g => g.JobFunctions)));

//get a sample group
var group = functions.First().JobFunctionGroup;

//group.JobFunctions contains the first item TWICE (probably because we resolved the group through that item
var result = group.JobFunctions.OrderBy(f => f.JobFunctionNbr);

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 31-Oct-2011 15:43:34