亚音速错误:ORDER BY 子句无效......,除非还指定了 TOP 或 FOR XML
我正在使用 Subsonic 2.1,并且在下一个查询时遇到错误:
SqlQuery queryResTitle = new Select(
new Aggregate(ResTitle.ResourceTitleIDColumn, "ResourceTitleID", AggregateFunction.GroupBy),
new Aggregate(ResTitle.ResourceTitleColumn, "ResourceTitle", AggregateFunction.GroupBy),
new Aggregate(VenVendor.TitleColumn, "Title", AggregateFunction.GroupBy),
new Aggregate(ResTitleStatus.StatusColumn, "Status", AggregateFunction.GroupBy))
.From(Tables.ResTitleOngoing)
.InnerJoin(ResTitleStatus.ResourceTitleIDColumn, ResTitle.ResourceTitleIDColumn)
.LeftOuterJoin(VenVendor.VendorIDColumn, ResTitle.VendorIDColumn);
我收到错误:
“ORDER BY 子句在以下情况下无效: 视图、内联函数、派生函数 表、子查询和公用表 表达式,除非 TOP 或 FOR XML 是 还指定了“
我还添加了 .Top("1")
但我仍然遇到相同的错误。
I'm using Subsonic 2.1 and I'm having an error with the next query:
SqlQuery queryResTitle = new Select(
new Aggregate(ResTitle.ResourceTitleIDColumn, "ResourceTitleID", AggregateFunction.GroupBy),
new Aggregate(ResTitle.ResourceTitleColumn, "ResourceTitle", AggregateFunction.GroupBy),
new Aggregate(VenVendor.TitleColumn, "Title", AggregateFunction.GroupBy),
new Aggregate(ResTitleStatus.StatusColumn, "Status", AggregateFunction.GroupBy))
.From(Tables.ResTitleOngoing)
.InnerJoin(ResTitleStatus.ResourceTitleIDColumn, ResTitle.ResourceTitleIDColumn)
.LeftOuterJoin(VenVendor.VendorIDColumn, ResTitle.VendorIDColumn);
I'm getting the error:
"The ORDER BY clause is invalid in
views, inline functions, derived
tables, subqueries, and common table
expressions, unless TOP or FOR XML is
also specified"
I also added .Top("1")
but I still got the same error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该调试 SubSonic 返回的生成查询:
并在您最喜欢的数据库管理工具中执行它。
也许你可以弄清楚出了什么问题。
You should debug the generated query that SubSonic returns:
and execute it in your favorite database administration tool.
Maybe you can figure out what's going wrong.