开发者

Subsonic error: The ORDER BY clause is invalid...., unless TOP or FOR XML is also specified

开发者 https://www.devze.com 2023-03-14 10:38 出处:网络
I\'m using Subsonic 2.1 and I\'m having an error with the next query: SqlQuery queryResTitle = new Select(

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 s开发者_开发技巧pecified"

I also added .Top("1") but I still got the same error.


You should debug the generated query that SubSonic returns:

var queryString = queryResTitle.BuildSqlStatement();

and execute it in your favorite database administration tool. Maybe you can figure out what's going wrong.

0

精彩评论

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

关注公众号