I have just found what looks to be the fastest way to get a limited subset of child entities per parent entity (the parent entity 'equ' primary key is tag_number below - child is wko) from a relational constraint in sql server. I'm now perplexed as to how to implement this in LLBLGen.
My Query is:
select wko2.* from ttt.wko wko2 INNER JOIN (
select ttt.wko.wo_number,
row_number() over (partition by tag_number order by reqst_date desc) as tag_counts
from ttt.wko) wko1 on wko1.wo_number= wko2.wo_number and tag_counts<=5 INNER JOIN ttt.equ equ on equ.tag_number=wko2.tag_number and equ.fac='FAC1' or equ.fac='FAC2'
any push in the right direction would be great!
thanks
andrew
ps.
in fact i'd like to do this as a prefetch path....with equ...
but IExpression doesnt seem right, neither does DbFunctionCall....
IPredicate seems like it could be the go...but row_number requires the subselect, and seems like overkill... anyone had a go at direct sql->entitycollection parsing (efficient?) ? hmmm...
pps.
maybe it might work with..
bucket.PredicateExpression.Add(new FieldCompareSetPredicate(
wko.tag_number, null, new EntityField2("gettags", DbFunctionCall([callafunctiontogetlistofgoodtags], null, SetOperator.In, null));
where
callafunctiontogetlistofgoodtags is an abbreviated sql query of the one above?
hmmm....