Fluent nHibernate 某种平板
我有一个问题(显然:)) 是否可以以这种方式在 nHibernate 中进行动态查询... 我有很多表(让我们说:用户,城市,国家,大陆,...)是否可以展平这些数据,所以我不需要知道这些表之间的连接(获取用户的大陆,而不需要连接用户。城市、城市.国家、国家.大陆)?
重点是我想要某种扁平化数据,以便用户可以在用户界面上动态选择数据,而无需知道应用程序背后的数据模型?
如果有人至少告诉我如何做到这一点,或者如果可能的话,那就太好了......
网络上的一个例子是 GoogleAnalytics 自定义报告(您可以在 UI 上拖动维度和指标并获取结果)
i have one problem (obviously :) )
Is it possible to make dynamic queries in nHibernate in that way...
I have many tables (let we say: User, City, Country, Continet,...) is it possible to flaten this data so i do not need to know joins between this tables (get continent for user, without making join user.city, city.country, coutry.continent)?
The point is i want to some kind flatten data, so user can dynamically select data on user interface without knowing data model behind application?
It will be great that someone gave me at least idea how to make this, or if it's possible...
One example on web is GoogleAnalytics Custom reports (you can drag dimensions and metrics on UI and get results)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您说您正在使用 Fluent NHibernate,这意味着,假设您的域模型结构正确,您不需要使用任何联接。
“扁平化”数据是 UI 问题,而不是数据库问题,因此除非绝对必要,否则不应扁平化数据模型或简化 UI 数据模型。
假设您有以下实体:
如果您想按特定国家/地区过滤用户,则相应的 LINQ 查询(假设为 NHibernate 3)将为:
You said you're using Fluent NHibernate, which means that, assuming your domain model is structured correctly, you should not need to use any joins.
"Flattening" the data is a UI concern, not a database concern, so you shouldn't flatten your data model or simplify it for the UI unless you absolutely have to.
Let's assume you have the following entities:
If you want to filter users by a certain country, the LINQ query for this (assuming NHibernate 3) would be: