Get Min datetime using predicate expression

Posts   
 
    
wengf2086
User
Posts: 1
Joined: 02-Aug-2024
# Posted on: 02-Aug-2024 20:36:28   
  • LLBLGen Pro v5.8
  • Using adapter and .NET version
  • SQL Server 2014 Management Studio

I'm having trouble getting the record with the minimum datetime for a field using a predicate expression. I've tried the following so far:

Dim transactionPredicateExpression As New SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression()
transactionPredicateExpression.AddWithAnd(
    SD.LLBLGen.Pro.ORMSupportClasses.AggregateFunction.Min(SalesData.Fields.TransactionDate) < thresholdDate)

Dim minTransactionDatePredicate As New SD.LLBLGen.Pro.ORMSupportClasses.FieldCompareSetPredicate(
    SalesData.Fields.TransactionDate,
    SalesData.Fields.TransactionDate,
    SD.LLBLGen.Pro.ORMSupportClasses.AggregateFunction.Min,
    SD.LLBLGen.Pro.ORMSupportClasses.SetOperator.Equal,
    Nothing
)

but both are incorrect.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39729
Joined: 17-Aug-2003
# Posted on: 03-Aug-2024 07:35:31   

Perhaps a SQL query what you're after might help? These are predicates but without the context in where you want to use them, they're not telling much.

A minimum date time is always the minimum value in a set, so basically: where x > (select min(datefield) from table)

Frans Bouma | Lead developer LLBLGen Pro