Open pjs-stockhouse opened 5 years ago
This bug only affects SQL Server and is related to the fact that you can not set parameter values to NULL in SQL Server, you have to use DBNull.Value instead.
This bug is fixed in version 2.0.7 of the Prius.SqlServer package.
Code below works fine when BenchmarkName has a value, but if it's null then it comes back with an exception saying the parameter isn't found. It seems as though the type can't properly be inferred at runtime for null values.
using (var command = _commandFactory.CreateStoredProcedure("Migration.usp_UpdateMSPortfolio")) { // ... command.AddParameter("BenchmarkName", portfolio.BenchmarkName); // ... }
15:54 SHVANSIDORSKY kentico cms Procedure or function 'usp_InsertMSPortfolio' expects parameter '@BenchmarkName', which was not supplied. ADDITIONAL INFO: 610 EXCEPTION: Procedure or function 'usp_InsertMSPortfolio' expects parameter '@BenchmarkName', which was not supplied. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource
1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Prius.SqlServer.Connection.ExecuteNonQuery() in d:\Git\Martin\Prius\Prius.SqlServer\Connection.cs:line 328 at Prius.Orm.Connections.Context.ExecuteNonQuery(ICommand command) at GetMSPortfolioDataTask.CreatePortfolio(MigrationPortfolio portfolio) in c:\Projects\Redux_master\KenticoCMS\App_Code\Stockhouse\ScheduledTasks\GetMSPortfolioDataTask.cs:line 582 `