相关疑难解决方法(0)

使用HqlBasedQuery参数化HQL IN子句?

你如何传递Nhibernate HQL中'in'子句的列表?

例如

// data input from the user interface, not known at compile time
object[] productIds = {1, 17, 36, ... }; 
string hqlQuery = @"
                from Product as prod
                where prod.Id in ( ? )";
HqlBasedQuery query = new HqlBasedQuery(typeof(Product), hqlQuery, productIds)
ActiveRecordMediator.ExecuteQuery(query);
Run Code Online (Sandbox Code Playgroud)

现在,这不会起作用,就像我希望的那样!我真的坚持做这样的事情:

// data input from the user interface, not known at compile time
object[] productIds = {1, 17, 36, ... }; 
string hqlQuery = @"
                from Product as prod
                where prod.Id in ( {0} )"; …
Run Code Online (Sandbox Code Playgroud)

c# nhibernate castle-activerecord hql

6
推荐指数
1
解决办法
4615
查看次数

标签 统计

c# ×1

castle-activerecord ×1

hql ×1

nhibernate ×1