Selecting rows with bitmask filter

Posts   
 
    
rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 22-Jun-2006 13:57:08   

Hi Guys,

Again another quickie as I am struggling to find what is wrong with my code and if I am using this bitmask stuff properly. I need to select rows which bit 0 and bit 1 set in column: Cop_checkoptions. I have 2 rows that satisy this requirement but I only get the first row that satisfies this requirement. The code I use to generate the filter is as follows, is this correct? Interestingly on an update of rows I use this code with no problems... and I have checked the column values visually so I am pretty sure its not me being stupid! (ahem)

for(int i=0; i < 32; i++) { uint bit = (uint)System.Math.Pow(2, i);

if ((bit & CheckedOptions) > 0) {
    filter.Add(new FieldCompareExpressionPredicate(
                        CustomerOptionFields.Cop_checkoptions, ComparisonOperator.Equal,
                        new Expression(CustomerOptionFields.Cop_checkoptions, ExOp.BitwiseAnd, (bit & (uint)0x7FFF))));
}

}

Many thanks

Richard

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 22-Jun-2006 16:14:16   

Dupe of :[http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=6661](http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=6661)

Frans Bouma | Lead developer LLBLGen Pro