SubSonic 3.0.0.3 | SimpleRepository - OrderByDescending和.First()

时间:2009-08-12 12:16:23

标签: subsonic subsonic3

此代码在SQL Express 2008上运行良好:

    return _repository.GetInstructions()
        .Where(x => x.PublishedDate != null)
        .OrderByDescending(x => x.PublishedDate)
        .First();

但是当使用SQL Server 2000运行时,它会中断。 这是错误。如果有人想看,我会发布跟踪。

 FailedSystem.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '('.

这是追踪:

TestSqlITInstructionRepository.Should_Get_Latest_ITInstruction : FailedSystem.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '('.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at SubSonic.DataProviders.DbDataProvider.ExecuteReader(QueryCommand qry) in DbDataProvider.cs: line 137
at SubSonic.Linq.Structure.DbQueryProvider.Execute<T>(QueryCommand`1 query, Object[] paramValues) in C:\Documents and Settings\nobody\My Documents\subsonic-SubSonic-3.0-8a52a0913ac0b8542d5d041262046c497387223f\subsonic-SubSonic-3.0-8a52a0913ac0b8542d5d041262046c497387223f\SubSonic.Core\Linq\Structure\DbQueryProvider.cs: line 280
at lambda_method(ExecutionScope )
at SubSonic.Linq.Structure.DbQueryProvider.Execute(Expression expression) in C:\Documents and Settings\nobody\My Documents\subsonic-SubSonic-3.0-8a52a0913ac0b8542d5d041262046c497387223f\subsonic-SubSonic-3.0-8a52a0913ac0b8542d5d041262046c497387223f\SubSonic.Core\Linq\Structure\DbQueryProvider.cs: line 131
at SubSonic.Linq.Structure.QueryProvider.System.Linq.IQueryProvider.Execute<S>(Expression expression) in C:\Documents and Settings\nobody\My Documents\subsonic-SubSonic-3.0-8a52a0913ac0b8542d5d041262046c497387223f\subsonic-SubSonic-3.0-8a52a0913ac0b8542d5d041262046c497387223f\SubSonic.Core\Linq\Structure\QueryProvider.cs: line 45
at System.Linq.Queryable.First<TSource>(IQueryable`1 source)
at Kiss.Test.Repositories.TestSqlITInstructionRepository.Should_Get_Latest_ITInstruction() in TestSqlITInstructionRepository.cs: line 73 

2 个答案:

答案 0 :(得分:1)

我不认为SubSonic完全支持MS SQL 2000。 我自己的发现表明,第一个()发生了TOP(1) 对于MS SQL 2000,它应该是TOP 1,没有括号

答案 1 :(得分:0)

SubSonic文档(http://subsonicproject.com/docs/Supported_Databases)表示它支持“SQL Server(200-2008)”,这意味着它可能是一个错误。我想你应该把它作为一个问题提交给SubSonic github网站。