SubSonic3: Method “FirstOrDefault” throws exception with SQL Server 2000

旧巷老猫 提交于 2019-12-02 11:58:14

I don't know SubSonic, but Hibernate has different dialects of SQL you can tell it to use, might want to see if there is any way to tell it to use a dialect for SQL 2000

Dave Hogan

This is a problem I've encountered too and unfortunately the code to generate the TOP is generated in the SubSonic Dependency and cannot be changed in the TT templates.

In the SubSonic source under TSqlFormatter.cs class is a method

protected override Expression VisitSelect(SelectExpression select)

...

if (select.Take != null)
            {
                sb.Append("TOP (");
                this.Visit(select.Take);
                sb.Append(") ");
            }

....

Removing the brackets in db.Append should fix the issue for SQL but I'm not sure whether this may break other providers such as SQL Compact Edition?

I raised it here: SubSonic Bug with TOP keyword? before I read you query.

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!