开发者

Nested Select in LLBLGen

开发者 https://www.devze.com 2022-12-15 03:44 出处:网络
So, I have the following tables: Using LLBLGen 2.6 (Adapter Version - No Linq), SQL Server, and .NET 3.5, how would I write the following query?

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

精彩评论

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

关注公众号