bitmask operations

Posts   
 
    
rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 31-May-2006 13:30:55   

Hi Guys,

A really quick question. I would like to be able to set a bit on a column to 1 or 0, for example, I need to reset bit 2 on all clients (AND with 0xF3). Is there a way to do this without the use of a stored procedure?

I dont really want to do this in code, and was hoping that I could somehow run the sql command

update subcategory set sc_active = sc_active | 0x02

or something like this through the tool.

I guess its something with a collection but I have looked at the documentation and cant see.

Apologies if this is staring me in the face but just need a pointer to get me on my way

Many thanks

Richard

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 31-May-2006 14:18:24   

You can do this with an expression and a bitwise operator (BitwiseAnd)

Please refer to the LLBLgen Pro documentation manual "Using the generated code -> Field expressions and aggregates" read the paragraph Expressions in entity updates

rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 31-May-2006 16:09:35   

Many thanks for your reply, for anyones info:

//The new filter to use IExpression updateExpression = new Expression(CustomerOptionFields.Cop_checkoptions, ExOp.BitwiseAnd, ~filter);

CustomerOptionEntity options = new CustomerOptionEntity();

options.Fields[(int)CustomerOptionFieldIndex.Cop_checkoptions].ExpressionToApply = updateExpression;

CustomerOptionCollection multiOptions = new CustomerOptionCollection();

// no filter is specified, everybody gets 10% extra, but you could of course // specify a filter to limit the scope of the update. multiOptions.UpdateMulti(options, null);