如何选择只在我的NHibernate查询中的一些列? [英] How to select only a few columns in my NHibernate query?

查看:99
本文介绍了如何选择只在我的NHibernate查询中的一些列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个一类一表映射;遗憾的是这款表有110+列,查询需要很长时间的过程,尤其是当大部分时间我只想要查看小于10列。

I have a one class to one table mapping; unfortunately this table has 110+ columns, and queries take a long time process, especially when most of the time I only want to view <10 columns.

我的问题是,该查询是基于用户想要看什么动态生成的。我真的不能创建具有不同的列不同的映射,因为那里将是一个非常大的数字组合。我使用的标准API来生成查询。我还可以用它来只选择用户想要的列?或一些其他的方法?

My problem is that the queries are dynamically generated based on what the user wants to look at. I can't really create different mappings with different columns because there would be a very large number of combinations. I'm using the criteria API to generate the queries. Can I also use this to only select the columns the user wants? Or some other method?

感谢

推荐答案

使用 ProjectionList 选择您想要的列。 见这里的例子。

Use a ProjectionList to select the columns you want. See here for the examples.

这篇关于如何选择只在我的NHibernate查询中的一些列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆