nhibernate审计查询
我在我的项目中使用 NHibernate,并使用事件侦听器实现了审核功能。
我现在需要取回这些数据,我想完全按照数据库中的情况返回它,我不需要带有关系的丰富对象模型,我想要的只是任何关系的 ID。
我基本上只是想显示一个审核日志(它本质上是您在 sql 中打开表时看到的内容的副本)。
我需要能够对许多表执行此操作,而我所拥有的只是审核表名称,是否有一种通用方法可以让 NHibernate 查询表并仅将结果作为数据表或类似的简单方法返回没有定义的模型吗?
所以本质上我希望 NHibernate 这样做:
SELECT * FROM "tablename"
然后以某种通用的方式返回它,我可以将其放入网格中并让它自动生成列。
I'm using NHibernate on my project and have implemented auditing functionality using event listeners.
I now need to get this data back, I want to return it exactly as it is in the database I dont need a rich object model with relationships all I want is the IDs of any relationships.
I am basically just trying to show an audit log (which is essentially a copy of what you would see if you opened the table up in sql).
I need to be able to do this for many tables though and all I have is the audit table name, is there a generic way to get NHibernate to query a table and just return the results as a datatable or something simple like that that doesn't have a defined model?
So essentially I want NHibernate to do this:
SELECT * FROM "tablename"
and then return it in some generic way that I can put in a grid and have it autogenerate the columns off it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下命令来查询未映射的对象。
更多:http://lostechies.com/jimmybogard/ 2010/06/30/ad-hoc-mapping-with-nhibernate/
You could use the following to query unmapped objects.
More: http://lostechies.com/jimmybogard/2010/06/30/ad-hoc-mapping-with-nhibernate/
您可以使用“select”方法仅获取所需的字段:
you can use the 'select' method to get only the fields you want: