SubSonic .Paged() 查询返回重复记录
使用 SubSonic (2.2) SqlQuery 对象,我正在查询一个包含另一个表中不同行的视图。但是,查询结果包含视图中某些行的多行。看来是因为在查询中生成了临时表上的联接来实现分页。如何避免这种行重复?
加分点:我必须使用视图,因为 SubSonic 无法同时执行 .Paged() 和 .Distinct() 。为什么不呢?
Using a SubSonic (2.2) SqlQuery object, I am querying a view that contains distinct rows from another table. The results of the query, however, contain multiple rows for certain rows in the view. It appears to be because of a join on a temporary table in the query generated to achieve paging. How can I avoid this duplication of rows?
Bonus points: I have to use the view because SubSonic can't do .Paged() and .Distinct() at the same time. Why not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我没记错的话,你必须在正确的位置使用不同的。
两个语句都可以编译,但第一个语句会生成无效的 sql 代码。调试 SubSonic SqlQueries 的一个很好的起点是生成输出:
另一个解决方案可能是使用 Group 而不是 unique,这样您就可以首先避免视图。
If I remember correctly you have to use distinct on the right position.
Both statements compile but the first generates invalid sql code. A good starting point for debugging SubSonic SqlQueries is to generate the output:
Another solution could be to use Group instead of distinct so you can avoid the view in the first place.