Need left join in typed list query

Posts   
 
    
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 30-Mar-2005 00:09:49   

Can anyone tell me how I can make one of the relationships in this typed list query a left join? I have a relation between Product.ProductID and ProductBlurb.ProductID, and since I can't expect a blurb to always be there I need to make this join a left join so I still get the product from the query.


public FramesTypedList GetFramesForManufacturer(string styleGeneral, string manufacturer)
        {
            FramesTypedList frames = new FramesTypedList();
            IRelationPredicateBucket filter = (IRelationPredicateBucket)frames.GetRelationInfo();
            filter.PredicateExpression.Add( PredicateFactory.CompareValue(ProductVersionFieldIndex.ActiveState, ComparisonOperator.Equal, ProductManager.ACTIVE_STATE_ACTIVE ) );
            filter.PredicateExpression.Add( PredicateFactory.CompareValue(CompanyFieldIndex.CompanyName, ComparisonOperator.Equal, manufacturer) );
            filter.PredicateExpression.Add( PredicateFactory.CompareValue(RidingStyleFieldIndex.StyleGeneral, ComparisonOperator.Equal, styleGeneral) );
            // Get fields and apply SUM() and Group By clause.
            ResultsetFields fields = (ResultsetFields)frames.GetFieldsInfo();
            fields["RPPrice"].AggregateFunctionToApply = AggregateFunction.Min;
            fields["MfrGrams"].AggregateFunctionToApply = AggregateFunction.Min;
            IGroupByCollection  groupBy = new GroupByCollection();
            for(int i = 0; i < fields.Count; i++)
            {
                IEntityField2 field = fields[i] as IEntityField2;
                if ( field.AggregateFunctionToApply == AggregateFunction.None )
                    groupBy.Add( field );
            }
            DataAccessAdapter adapter = new DataAccessAdapter();
            adapter.FetchTypedList( fields, frames, filter, 0, null, false, groupBy );
            return frames;
        }

Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 30-Mar-2005 07:47:30   

Set the ObeyWeakRelations porperty of the bucketfilter's Relations property

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 30-Mar-2005 09:51:51   

You can indeed use the obeyweakrelations setting OR use the Add() overload on the Relations collection which accepts a JoinHint simple_smile

Frans Bouma | Lead developer LLBLGen Pro