Cast and isnumeric functions in where clause

Posts   
 
    
Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 27-Jul-2005 16:57:30   

I am trying to accomplish the equivilant of the following SQL:

SELECT ImageId, BarcodeId, ScanStatus, CAST(QualityFactor AS numeric) AS NumericQualityFactor

FROM Image

WHERE (isnumeric(BarcodeId) = 1) AND (ScanStatus = 'Success') AND (NOT (BarcodeId IS NULL)) AND (BarcodeId <> '') AND (isnumeric(QualityFactor) = 1) AND (CAST(QualityFactor AS decimal) > 69)

ORDER BY ImageId

How do I filter using the CAST and the isnumeric functions in LLBL?

Thanks,

Tom

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 27-Jul-2005 19:03:52   

CAST and Isnumeric aren't supported at the moment.

You can overcome this limitation by implementing a special version of the CompareValue predicate class. Derive a class from FieldCompareValuePredicate and override ToQueryText() (please see the runtime library sourcecode on your harddisk for details about this class). In there simply wrap the text produced by the base class with CAST(... ) or Isnumeric( ).

Then in your OWN code, instead of doing predicateExpression.Add(PredicateFactory.CompareValue(...)) you do: predicateExpression.Add(new IsNumericCompareValuePredicate( EntityFieldFactory.Create(fieldindex.Fieldname), operator, value))..

etc.

Frans Bouma | Lead developer LLBLGen Pro
Barney
User
Posts: 29
Joined: 27-Jul-2005
# Posted on: 27-Jul-2005 19:59:04   

Thanks,

The simplest way for me would be to create a view in the database, but I cannot change the database as it's from a vendor of a piece of lab equipment.

Are isnumeric and cast on the list for future enhancements?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 28-Jul-2005 11:15:25   

Barney wrote:

Thanks,

The simplest way for me would be to create a view in the database, but I cannot change the database as it's from a vendor of a piece of lab equipment.

Are isnumeric and cast on the list for future enhancements?

They're on the list for 2.0, but that's not available before the end of 2005. Adding the predicate classes now is pretty straight forward, it's a couple of lines actually. As the predicates are very DB specific, they're not added to the pack for now.

Frans Bouma | Lead developer LLBLGen Pro