开发者

Creating bitwise operator in LINQ to SQL?

开发者 https://www.devze.com 2023-03-17 21:41 出处:网络
I want to get this query at last: select * from tableName where columnName & 2 = 2 and c开发者_StackOverflow中文版olumnName & 4 = 4

I want to get this query at last:

 select * from tableName where columnName & 2 = 2 and c开发者_StackOverflow中文版olumnName & 4 = 4

How can I use LINQ to generate this script?


You can do bitwise operations in C# ( and in LINQ queries ) with either & or | depending on what bitwise operation you want.

var query =
            from row in context.tableName
            where (row.columnName & 2) == 2 && (row.columnName & 4) == 4
            select row


var query = from r in context.tableName 
    where r.columnName & 2 == 2 and r.columnName & 4 == 4
    select r;
0

精彩评论

暂无评论...
验证码 换一张
取 消