开发者

Complex LINQ SelectMany

I have a number of tables I need to join. Tables x,b,c join normally and I'll call that J1. Tables x,d are another normal join that I call J2.

Now I need to join J1 and J2 together. For every row in J1 there may be multiple related rows in J2. Table x has a date field among other conditions (which are easy to set up and are in the group join), but I need to get the latest/highest J2 row. Table x has a date field, and basically for every row in J1 I can have multiple rows in J2, and I need to get the most recent one.

I have the joins for J1 in place. The join for J2 is also in place, as first element in a GroupJoin on J1.

Where I am totally lost are two issues:

  • At one point I need to filter out by date. J1*x x entry must be later than J1's (there can be older ones).

  • The Select Many needs to take the most recent one, which would implicate some ordering, but I have not been successful at adding a sort. Where do I put that in? I have the GroupJoin, followed by t开发者_如何学JAVAhe SelectMany. Where do I put in the OrderBy?

Note I require lambda syntax; I can not rewrite it to another form.

Help is appreciated


Conditions:

1) J1 (Single line)(x,b,c) = J2 (Multiple line) (x,d)

2) J2.x has datefield for ordering

3) J2.x entry must be later than J1.x

4) J2.x filter out by date

if its correct

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜