2009-08-12 2 views
0

이 코드는 SQL Express를 2008 년 잘 작동 : SQL Server 2000을 사용하여 실행할 때SubSonic 3.0.0.3 | SimpleRepository - OrderByDescending 및 좁은 방()

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

하지만, 그것은 나누기. 여기에 오류가 있습니다. 누군가가보고 싶으면 추적을 게시 할 것입니다. 여기

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 
+0

이 쿼리뿐만 아니라 스택 추적을 생성하는 sql을 게시 할 수 있습니까? –

+0

문제입니다. 여기에 해결책을 게시했습니다. http://stackoverflow.com/questions/1397933/subsonic3-method-firstordefault-throws-exception-with-sql-server-2000/3466302#3466302 – DaveHogan

답변

1

내가 음속 완전히 2000 내 자신의 연구 결과는 좁은 방()가 TOP를 genarates을 나타냅니다 MS SQL을 지원합니다 생각하지 않는다 (1) MS의 SQL에 대한
2000 괄호가없는 TOP 1이어야합니다.

+0

사실입니다. 방금이 버그를 만났고 나는 당신의 대답으로 그것을 골랐다. 이제 SimpleRepository.Single을 All 대신에 사용하고 First 후에 사용합니다. – Tom

관련 문제