mysql - 如何通过 nhibernate/fluent nHibernate 使用 MYSQL BIT_COUNT 函数?

标签 mysql linq nhibernate fluent-nhibernate

我正在做一些巫术,需要使用 c#/linq/fluent-nhibernate 通过 bit_count 运算符对我的结果进行排序。

这是我当前的订单声明:

orderby m.InitiatorInventory & wanted descending

我真正想要的是这样的东西

orderby BIT_COUNT(m.InitiatorInventory & wanted descending)

这是Mysql函数:

http://dev.mysql.com/doc/refman/5.0/en/bit-functions.html#function_bit-count

最佳答案

您可以使用 CreateSQLQuery 或者您可以在 NHibernate 中注册您自己的 BIT_COUNT 方言:

public class MyDialect : MySqlDialect
{
    public MyDialect()
    {
        RegisterFunction("bit_count", new StandardSQLFunction("bit_count", null));
    }
}

更多信息 here .

关于mysql - 如何通过 nhibernate/fluent nHibernate 使用 MYSQL BIT_COUNT 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5668151/

相关文章:

php - 向用户显示以前上传的内容以供选择

mysql - 获取每列的不同值而无需重新执行相同的查询

mysql - Sequelize Op.iLike 使用 MySQL 抛出错误

c# - 如何找到最大差异为 5 的最大子集的大小?

c# - 正则表达式帮助 : My regex pattern will match invalid Dictionary

mysql - 具有多个连接的多个 mysql 表

c# - 在 Linq 中选择 Class(variable) 而不是 Select New Class{variable = x}

oracle - nhibernate,Oracle中的调用函数,返回sys refcursor

NHibernate 属性公式过滤器

c# - 关联引用未映射的类 (.net)