I have custom SqlClientDriver  that create wrapper for command

 public class CustomSqlDriver : SqlClientDriver
        {
        public override IDbCommand CreateCommand()
            {
            return new CommandWrapper( base.CreateCommand() );
            }
        }

CommandWrapper implements IDbCommand and have explicit operator to 
SqlCommand


public class CommandWrapper: IDbCommand
{
       private readonly IDbCommand _impl;

      public  static  explicit operator SqlCommand( 
sql_command_wrapper_with_timeout me ){
            return (SqlCommand)me._impl;
        }

        protected command_wrapper_impl( IDbCommand impl )
            {
            _impl = impl;
            }
}


nHibernate fails in SqlClientBatchingBatcher.cs  when try to cast my 
command  to SqlCommand

line 65:  _currentBatch.Append((System.Data.SqlClient.SqlCommand) 
batchUpdate);

System.InvalidCastException: Unable to cast object of type 'CommandWrapper' 
to type 'System.Data.SqlClient.SqlCommand'.

when i write same code  in test it works fine:

var testCommand = new CommandWrapper( new SqlCommand );
var sqlCommand = (SqlCommand)testCommand;

whats wrong?  in nH 3.1.0 all  works fine. broken when try to migrate my 
code.




-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/aoZYWZv3bS0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to