Cast in Where Clause

Posts   
 
    
Posts: 5
Joined: 10-Feb-2006
# Posted on: 08-Mar-2006 15:56:57   

I found this post http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=3807&HighLight=1 that mentions support for CAST coming in 2.0. I have a scenario where we need to construct the following condition in a where clause: WHERE bit_column = cast(1 as bit)

This is to support an index that we have on a bit field that has a very skewed distribution 95% 0, 5% 1 and is therefore a good candidate for an index eventhough it is a bit field. Anyway, essentially we need to force the optimizer to do an index seek rather than a scan and as is well known, the statement: WHERE bit_column = 1 causes the optimizer to convert the bit field to an int using a convert function which ultimately results in a scan rather than a seek.

We are running LLBLGenPro v1.0.2005.1, SQL Server 2005, is support for doing something like this built into this version of LLBLGenPro or do we still need to write a custom predicate or CompareValue overload?

Thanks in advance...

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-Mar-2006 09:04:32   

You should implement IExpression as in the following thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3829