我正在調試我的應用程序中的間歇性截斷錯誤。在我的記錄錯誤是這樣的:在nHibernate中調試「字符串或二進制數據將被截斷」錯誤
System.Data.SqlClient.SqlException: String or binary data would be truncated.
The statement has been terminated. Generated: Tue, 02 Nov 2010 03:55:18 GMT
NHibernate.Exceptions.GenericADOException: could not insert:
[DataModel.Product][SQL: INSERT INTO [Product] (Fields) VALUES (?, ?,...);
select SCOPE_IDENTITY()] --->
System.Data.SqlClient.SqlException: String or binary data would be truncated.
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
注意,誤差不用於拋出錯誤,只是佔位符的SQL提供的參數值:(?, ?,...)
。有沒有辦法從nHibernate中獲得這些?就像這樣:
try {
...
Session.Flush(); // throws
}
catch (GenericADOException ex) {
// want to get the bad parameter values,
// so I can re-throw a more helpful exception
}