tags:

views:

15

answers:

1

The TOP keyword in the generated SQL wraps the number in brackets (I persume for SQL compact support), however this errors on my SQL 2000 server as it doesn't expect the brackets.

Example C# Code:

var doc = Logic.Document.All().FirstOrDefault(d=> d.Guid == Request.QueryString["guid"]);

Produces the following SQL error:

Line 1: Incorrect syntax near '('.

as it generates the following SQL:

 exec sp_executesql N'SELECT TOP (1) .....'

If I execute the same SQL manually without the brackets the SQL executes just fine. Is this a bug?

A: 

After futher digging around the SubSonic SourceCode I answered a resolution here:

http://stackoverflow.com/questions/1397933/subsonic3-method-firstordefault-throws-exception-with-sql-server-2000/3466302#3466302

DaveHogan