IRelationPredicateBucket & IPrefetchPath2 with FetchEntity

Posts   
 
    
Posts: 12
Joined: 22-Nov-2005
# Posted on: 16-Feb-2006 22:42:38   

Is it possible using FetchEntity to supply both a relation (i.e. PersonEntity.Relations.DemographicsEntityUsingPersonOid) with a prefetch path (i.e. PersonEntity.PrefetchPathQualification)

I have a data model with Person 1:1 Demographics, and Person 1:M Qualifications and I wanted to achieve my fetch with a 2 query structure of


SELECT   *
FROM         dbo.Person INNER JOIN
                      dbo.Demographics ON dbo.Person.PersonOID = dbo.Demographics.PersonOID
WHERE PersonOID = @PersonOID

SELECT *
FROM Qualification
WHERE PersonOID = @PersonOID

Currently I am using prefetch paths and I am executing 3 queries when loading this single entity. This isn't causing issues, but I was wondering if this was possible some how with LLBLGenPro?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 17-Feb-2006 03:19:57   

SELECT * FROM dbo.Person INNER JOIN dbo.Demographics ON dbo.Person.PersonOID = dbo.Demographics.PersonOID WHERE PersonOID = @PersonOID

This won't be used to fill the Person Entity and the Demographics entity. It will always execute two queries, one to fill the Person and one to fill the Demographic as far as I know. Are you also using fields in the Demographic entity?

Posts: 12
Joined: 22-Nov-2005
# Posted on: 17-Feb-2006 03:40:40   

Well at the moment I have this code that loads a person entity, this will fire 3 individual queries. I definately use all the data that gets returned. But I was wondering if I could use a mix of relations and prefetches combined so that it fires only one inner join select and one select.



PersonEntity personData = new PersonEntity(personOID);

IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.PersonEntity);
prefetchPath.Add(PersonEntity.PrefetchPathDemographics);
prefetchPath.Add(PersonEntity.PrefetchPathQualification);

using(DataAccessAdapter adapter = new DataAccessAdapter(ConnectionString))
{
    adapter.FetchEntity(personData, prefetchPath);
}


Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-Feb-2006 07:47:29   

There is one Query fired for each entity or entity collection you fetch.

If possible you may use a TypedList, Typed View or dynamic List.