开发者

Nested Select in LLBLGen

So, I have the following tables:

Nested Select in LLBLGen

Using LLBLGen 2.6 (Adapter Version - No Linq), SQL Server, and .NET 3.5, how would I write the following query?

SELECT o.ObjectID 
FROM Object o 
INNER JOIN ObjectDetail d ON i.ObjectID = d.ObjectID 
WHERE d.CreatedDate = ( SELECT MAX(CreatedDate) 
                        FROM ObjectDetail
                        WHERE ObjectID = o.ObjectID
                      )

There will be more filtering, however it's not relevant to this, like if I had 开发者_JAVA百科an ObjectDetailType and I wanted the max ObjectDetail row for a certain type.

Also, it doesn't have to select o.ObjectID, any / all columns will be fine.


Solved it

PredicateExpression.AddWithAnd(
  new FieldCompareSetPredicate(
    ObjectDetailFields.CreatedDate,
    null,
    ObjectDetailFields.CreatedDate.SetAggregateFunction(AggregateFunction.Max),
    null,
    SetOperator.Equal,
    (ObjectFields.ObjectID == ObjectDetailsFields.ObjectID)
 )
);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜