Multiple conditions in left clause

Posts   
 
    
Posts: 5
Joined: 23-Jan-2014
# Posted on: 13-Oct-2014 12:23:06   

Hi,

How to write this in query factory :

select s.uitbericht_subtype_cd,s.kt_omschr_f,s.kt_omschr_n, COUNT(*) - 1 from tob_uitbericht_subtype s left join tob_uitbericht_ag ag on (s.uitbericht_subtype_cd = ag.uitbericht_subtype_cd and ag.gb_beheerder_id = '505593') left join tob_uitbericht u on ag.bericht_ag_id = u.bericht_ag_id where s.uitbericht_subtype_cd = 'CUS_LETTER' group by s.uitbericht_subtype_cd,s.kt_omschr_f,s.kt_omschr_n


select s.uitbericht_subtype_cd,s.kt_omschr_f,s.kt_omschr_n, COUNT(*) - 1
from tob_uitbericht_subtype s
left join tob_uitbericht_ag ag on (s.uitbericht_subtype_cd = ag.uitbericht_subtype_cd 
                                    and ag.gb_beheerder_id = '505593')
left join tob_uitbericht u on ag.bericht_ag_id = u.bericht_ag_id
where s.uitbericht_subtype_cd = 'CUS_LETTER'
group by s.uitbericht_subtype_cd,s.kt_omschr_f,s.kt_omschr_n

Tried this

q.From(qf.TobUitberichtSubtype.LeftJoin(qf.TobUitberichtAg) .On(TobUitberichtAgFields.UitberichtSubtypeCd == TobUitberichtSubtypeFields.UitberichtSubtypeCd && TobUitberichtAgFields.GbBeheerderId == userId) .LeftJoin(qf.TobUitbericht) .On(TobUitberichtFields.BerichtAgId == TobUitberichtAgFields.BerichtAgId));


q.From(qf.TobUitberichtSubtype.LeftJoin(qf.TobUitberichtAg)
                .On(TobUitberichtAgFields.UitberichtSubtypeCd == TobUitberichtSubtypeFields.UitberichtSubtypeCd
                 && TobUitberichtAgFields.GbBeheerderId == userId)
                .LeftJoin(qf.TobUitbericht)
                .On(TobUitberichtFields.BerichtAgId == TobUitberichtAgFields.BerichtAgId));

but '&&' is red underlined with following error :

In order to be applicable as a short circuit operator a user-defined logical operator ('SD.LLBLGen.Pro.ORMSupportClasses.Predicate.operator &(SD.LLBLGen.Pro.ORMSupportClasses.Predicate, SD.LLBLGen.Pro.ORMSupportClasses.Predicate)') must have the same return type as the type of its 2 parameters

Thank you, Olivier

PS : impossible to use short formatting (red color, underlining) inside code section when writing a post

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 13-Oct-2014 20:24:45   

LeftJoin() has an overload that accepts an IEntityRelation, which has a CustomFilter property which you can set with the additional predicate.