@@ -30,20 +30,23 @@ public class SqlClientSqlCommandSet : IDisposable
30
30
31
31
static SqlClientSqlCommandSet ( )
32
32
{
33
- var sysData = Assembly . Load ( " System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" ) ;
33
+ var sysData = typeof ( System . Data . SqlClient . SqlCommand ) . Assembly ;
34
34
sqlCmdSetType = sysData . GetType ( "System.Data.SqlClient.SqlCommandSet" ) ;
35
- Debug . Assert ( sqlCmdSetType != null , "Could not find SqlCommandSet!" ) ;
36
-
37
- connectionSetter = DelegateHelper . BuildPropertySetter < SqlConnection > ( sqlCmdSetType , "Connection" ) ;
38
- connectionGetter = DelegateHelper . BuildPropertyGetter < SqlConnection > ( sqlCmdSetType , "Connection" ) ;
39
- transactionSetter = DelegateHelper . BuildPropertySetter < SqlTransaction > ( sqlCmdSetType , "Transaction" ) ;
40
- commandTimeoutSetter = DelegateHelper . BuildPropertySetter < int > ( sqlCmdSetType , "CommandTimeout" ) ;
41
- batchCommandGetter = DelegateHelper . BuildPropertyGetter < System . Data . SqlClient . SqlCommand > ( sqlCmdSetType , "BatchCommand" ) ;
42
- doAppend = DelegateHelper . BuildAction < System . Data . SqlClient . SqlCommand > ( sqlCmdSetType , "Append" ) ;
43
- doExecuteNonQuery = DelegateHelper . BuildFunc < int > ( sqlCmdSetType , "ExecuteNonQuery" ) ;
44
- doDispose = DelegateHelper . BuildAction ( sqlCmdSetType , "Dispose" ) ;
35
+ if ( sqlCmdSetType != null )
36
+ {
37
+ connectionSetter = DelegateHelper . BuildPropertySetter < SqlConnection > ( sqlCmdSetType , "Connection" ) ;
38
+ connectionGetter = DelegateHelper . BuildPropertyGetter < SqlConnection > ( sqlCmdSetType , "Connection" ) ;
39
+ transactionSetter = DelegateHelper . BuildPropertySetter < SqlTransaction > ( sqlCmdSetType , "Transaction" ) ;
40
+ commandTimeoutSetter = DelegateHelper . BuildPropertySetter < int > ( sqlCmdSetType , "CommandTimeout" ) ;
41
+ batchCommandGetter = DelegateHelper . BuildPropertyGetter < System . Data . SqlClient . SqlCommand > ( sqlCmdSetType , "BatchCommand" ) ;
42
+ doAppend = DelegateHelper . BuildAction < System . Data . SqlClient . SqlCommand > ( sqlCmdSetType , "Append" ) ;
43
+ doExecuteNonQuery = DelegateHelper . BuildFunc < int > ( sqlCmdSetType , "ExecuteNonQuery" ) ;
44
+ doDispose = DelegateHelper . BuildAction ( sqlCmdSetType , "Dispose" ) ;
45
+ }
45
46
}
46
47
48
+ public static bool HasBatchImplementation => sqlCmdSetType != null ;
49
+
47
50
public SqlClientSqlCommandSet ( )
48
51
{
49
52
instance = Activator . CreateInstance ( sqlCmdSetType , true ) ;
0 commit comments