所以,我有以下表格:
使用LLBLGen 2.6(适配器版本 - No Linq),SQL Server和.NET 3.5,如何编写以下查询?
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 )
将有更多的过滤,但它与此无关,就像我有一个ObjectDetailType并且我想要特定类型的max ObjectDetail行.
此外,它不必选择o.ObjectID,任何/所有列都可以.
解决了它
PredicateExpression.AddWithAnd( new FieldCompareSetPredicate( ObjectDetailFields.CreatedDate, null, ObjectDetailFields.CreatedDate.SetAggregateFunction(AggregateFunction.Max), null, SetOperator.Equal, (ObjectFields.ObjectID == ObjectDetailsFields.ObjectID) ) );