Skip to content

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

@uin84101100

Description

@uin84101100

问题描述及重现代码:

// 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<MCliFile>().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? 及具体版本

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions