我正在做一些巫术,需要使用 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/