dotnetcore / dotnetcore/FreeSql

FreeSql 中,使用 Firebird 数据库生成的sql 语句,所有的位运算都是错的

Open
#2,156 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Description

#### 问题描述及重现代码:

```c#

// c# code

public enum CliState
{
None = 0,
Del = 1024
}

public class MCliFile
{
[Column(IsPrimary = true, StringLength = 16)]
public string efNo { get; set; }

public short efState { get; set; }

[Column(StringLength = 20)]
public string efName { get; set; }
}

string sql = fsql.Select().Where(c => (int)(c.cfState & (int)CliState.Del) == (int)CliState.Del).ToSql();
// 此时生成的 sql 语言为:
// SELECT a."cfNo", a."cfState", a."cfName" FROM "client_file" a WHERE ((a."cfState" & 1024) = 1024)
// 但是 Firebird 是不支持 &、|、^、~ 这几个 常用的 运算符的,这玩意要用 BIN_AND、BIN_OR、BIN_XOR、BIN_NOT
// 就边最最基本的 移位 <<、>> 都得用 BIN_SHL、BIN_SHR 来写
// 相对的 Bitwise Functions 请参见
// https://www.firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-functions-bitwise.html
```

#### 数据库版本
我用的 Firebird 的5.0.3,但我看手册 Firebird 全系列 应该都有这个问题

#### 安装的Nuget包
FreeSql 所有的包(包括最新的 3.5.303)都有这个问题

#### .net framework/. net core? 及具体版本

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.