HQLBasedQuery 到 ProjectionQuery Castle ActiveRecord/NHibernate
我正在尝试使用 Castle 进行查询并返回强类型数组或 IList 以便稍后在数据绑定中使用,因此从我读到的 ProjectionQuery 将是我的最佳选择,但我如何将其转换为投影查询:
HqlBasedQuery hql = new HqlBasedQuery(typeof(TrackingRule),
QueryLanguage.Hql,
"SELECT AC.TrackingRule FROM Account_Rule as AC WHERE AC.Account.ID = " + 63);
提前致谢
叶希亚·萨拉姆
I'm trying to query using Castle and return a strong-typed array or IList for later use in data binding, so from i read a ProjectionQuery would be my best choice, but how would i transform this to a projection query:
HqlBasedQuery hql = new HqlBasedQuery(typeof(TrackingRule),
QueryLanguage.Hql,
"SELECT AC.TrackingRule FROM Account_Rule as AC WHERE AC.Account.ID = " + 63);
Thanks In Advance
Yehia A.Salam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您只是想返回一个对象列表。投影查询通常用于仅返回某些列,这似乎不是您所需要的。
您可以使用现有的内容获得强类型的 ArrayList:
这是返回数组的替代方案:
It looks like you are just trying to return a list of objects. Projection queries are usually used to return only some columns, which doesn't appear to be what you need here.
You can get a strongly typed ArrayList with what you have:
Here's an alternative that returns an array: