Hi Folks,
Please forgive me if this issue sounds obvious. I'm still a little bit new to LLBLGEN. Great product by the way.
I seemed to have come across a problem with the usage of Today's date in a WHERE clause, when attempting to use predicates. I've been asked not to use stored procedures for any SELECT statements, so I'm using predicates instead.
The Select Statement
When I use Microsoft SQL Server Query Analyser, I have the following SELECT statement:
SELECT *
FROM customers c
WHERE DATEDIFF( d, c.pending_delete_date, GETDATE() ) > 6
In other words, give me a list of all customers where the difference between the customer pending delete date and todays date is greater than 6 days.
The problem
I'm having a bit of trouble constructing the WHERE clause via the use of predicates and expressions in LLBLGEN. I've written the following code (we're using Adapters), but it doesn't appear to be working:
Dim eLeftOperand As New Expression( DateTime.Now, ExOp.Sub, CustomerFields.Pending_delete_date )
dtCalculatedPendingDateField = CustomerFields.Pending_delete_date.SetExpression( eLeftOperand )
Dim pCompareValue As New FieldCompareValuePredicate( dtCalculatedPendingDateField, Nothing, ComparisonOperator.GreaterThan, 6 )
Dim pPredExpression As New RelationPredicateBucket
pPredExpression.PredicateExpression.Add( pCompareValue )
Me.oAdapter.FetchEntityCollection( oCustomers, pPredExpression )
I'm not sure if I'm on the right path in regards to the VB.NET code above matching the WHERE clause in the SQL.
Any help would be apreciated.
Many thanks in advance guys.
Cheers
VS