开发者

Nhibernate SQL named queries and projection

I've mapped a class to a SQL Server table and use an SQL named query to retrieve some rows from it. Also I don't want all of the columns on certain pages (e.g. if it's a document, I want to display its full content on a "View Details" page only, while its title can be on a list and the "View Details" page.

If I don't select all of the columns of the table in question, I get an IndexOutOfRangeException on the columns that I've left out.

Is there a way to project only the columns I'm interested in on named queries 开发者_如何学Pythonor do I have to create extra POCOs for the different scopes of the application?

Regards, F.


You want NHibernate ad-hoc mapping.

P.S.: Like the others have said, you should at least take a look at HQL, Criteria or NHibernate.Linq. And to easily handle the generated SQL, everyone uses the NHibernate Profiler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜