Preform left join on prefetch path

Posts   
 
    
ajwalters
User
Posts: 4
Joined: 11-Oct-2006
# Posted on: 18-Apr-2007 20:26:51   

LLBLGen Pro Version: 1.0.2005.1 Final Database: SQL 2005

Hello,

I'm having issues trying to preform a left-join prefetch on a relation. Basically, i have a list of skills (ListIndustrialSkills) which applicant's can select. When they make this selection, a record is placed in ApplicantIndustrialSkill (holds ListIndustrialSkillID which is primary key of ListIndustrialSkills). ApplicantIndustrialSkill also houses AppID, which is the primary key of the application.

My ListIndustrialSkills has a field ApplicantIndustrialSkills, which holds the EntityCollection of all ApplicantIndustrialSkills w/ ApplicantIndustrialSkills.ListIndustrialSkillID of that particular skillID.

I'm wondering if there is anyway for me to preform a left join on this relation. My goal is to pull down ALL of the ListIndustrialSKills, as well as any ApplicantIndustiralSkill that MAY have been selected by the particular applicant (ApplicantIndustrialSkill = particular AppID)

So, that if i have the AppID, i can pull down all the ListIndustrialSkills, plus, if the appID matches, the ListIndustrialSkill will also have it's ApplicantIndustrialSkill populated.

Does this make sense? I simply want my prefetch to preform a left-join.

THanks in advance, Adam

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Apr-2007 08:50:10   

Hello Adam, you can use per-node filters. Here is a example with Adapter scenario in v1.0.2005.1 Final. So, in this case you don't need to specify a left joinsimple_smile

Statement : ALL Employees with Orders, only orders from customer 'ALFKI' will be attached.

// collection to fill
EntityCollection employees = new EntityCollection(new EmployeesEntityFactory());

// path: employees -> orders (only orders from customer 'ALFKI'
IPrefetchPath2 path = new PrefetchPath2((int)EntityType.EmployeesEntity);
path.Add(EmployeesEntity.PrefetchPathOrders, 0, 
    new PredicateExpression(
        PredicateFactory.CompareValue(OrdersFieldIndex.CustomerId, ComparisonOperator.Equal, "ALFKI")));

// retrieve ALL employees with orders attached (only orders from customer 'ALFKI' will be attached.
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
    adapter.FetchEntityCollection(employees, null, path);
}
David Elizondo | LLBLGen Support Team