@@ -174,10 +174,6 @@ public SqlConnection(string connectionString, SqlCredential credential) : this()
174
174
{
175
175
throw ADP . InvalidMixedArgumentOfSecureCredentialAndIntegratedSecurity ( ) ;
176
176
}
177
- else if ( UsesContextConnection ( connectionOptions ) )
178
- {
179
- throw ADP . InvalidMixedArgumentOfSecureCredentialAndContextConnection ( ) ;
180
- }
181
177
else if ( UsesActiveDirectoryIntegrated ( connectionOptions ) )
182
178
{
183
179
throw SQL . SettingCredentialWithIntegratedArgument ( ) ;
@@ -459,49 +455,39 @@ public bool StatisticsEnabled
459
455
}
460
456
set
461
457
{
462
- if ( IsContextConnection )
458
+ if ( value )
463
459
{
464
- if ( value )
460
+ // start
461
+ if ( ConnectionState . Open == State )
465
462
{
466
- throw SQL . NotAvailableOnContextConnection ( ) ;
463
+ if ( _statistics == null )
464
+ {
465
+ _statistics = new SqlStatistics ( ) ;
466
+ _statistics . _openTimestamp = ADP . TimerCurrent ( ) ;
467
+ }
468
+ // set statistics on the parser
469
+ // update timestamp;
470
+ Debug . Assert ( Parser != null , "Where's the parser?" ) ;
471
+ Parser . Statistics = _statistics ;
467
472
}
468
473
}
469
474
else
470
475
{
471
- if ( value )
476
+ // stop
477
+ if ( _statistics != null )
472
478
{
473
- // start
474
479
if ( ConnectionState . Open == State )
475
480
{
476
- if ( _statistics == null )
477
- {
478
- _statistics = new SqlStatistics ( ) ;
479
- _statistics . _openTimestamp = ADP . TimerCurrent ( ) ;
480
- }
481
- // set statistics on the parser
481
+ // remove statistics from parser
482
482
// update timestamp;
483
- Debug . Assert ( Parser != null , "Where's the parser?" ) ;
484
- Parser . Statistics = _statistics ;
483
+ TdsParser parser = Parser ;
484
+ Debug . Assert ( parser != null , "Where's the parser?" ) ;
485
+ parser . Statistics = null ;
486
+ _statistics . _closeTimestamp = ADP . TimerCurrent ( ) ;
485
487
}
486
488
}
487
- else
488
- {
489
- // stop
490
- if ( _statistics != null )
491
- {
492
- if ( ConnectionState . Open == State )
493
- {
494
- // remove statistics from parser
495
- // update timestamp;
496
- TdsParser parser = Parser ;
497
- Debug . Assert ( parser != null , "Where's the parser?" ) ;
498
- parser . Statistics = null ;
499
- _statistics . _closeTimestamp = ADP . TimerCurrent ( ) ;
500
- }
501
- }
502
- }
503
- _collectstats = value ;
504
489
}
490
+ _collectstats = value ;
505
491
}
506
492
}
507
493
@@ -512,21 +498,6 @@ internal bool AsyncCommandInProgress
512
498
set => _AsyncCommandInProgress = value ;
513
499
}
514
500
515
- internal bool IsContextConnection
516
- {
517
- get
518
- {
519
- SqlConnectionString opt = ( SqlConnectionString ) ConnectionOptions ;
520
- return UsesContextConnection ( opt ) ;
521
- }
522
- }
523
-
524
- // Is this connection is a Context Connection?
525
- private bool UsesContextConnection ( SqlConnectionString opt )
526
- {
527
- return opt != null && opt . ContextConnection ;
528
- }
529
-
530
501
private bool UsesActiveDirectoryIntegrated ( SqlConnectionString opt )
531
502
{
532
503
return opt != null && opt . Authentication == SqlAuthenticationMethod . ActiveDirectoryIntegrated ;
@@ -868,15 +839,8 @@ public int PacketSize
868
839
// can just return what the connection string had.
869
840
get
870
841
{
871
- if ( IsContextConnection )
872
- {
873
- throw SQL . NotAvailableOnContextConnection ( ) ;
874
- }
875
-
876
- SqlInternalConnectionTds innerConnection = ( InnerConnection as SqlInternalConnectionTds ) ;
877
842
int result ;
878
-
879
- if ( innerConnection != null )
843
+ if ( InnerConnection is SqlInternalConnectionTds innerConnection )
880
844
{
881
845
result = innerConnection . PacketSize ;
882
846
}
@@ -885,6 +849,7 @@ public int PacketSize
885
849
SqlConnectionString constr = ( SqlConnectionString ) ConnectionOptions ;
886
850
result = constr != null ? constr . PacketSize : SqlConnectionString . DEFAULT . Packet_Size ;
887
851
}
852
+
888
853
return result ;
889
854
}
890
855
}
@@ -970,11 +935,6 @@ public string WorkstationId
970
935
{
971
936
get
972
937
{
973
- if ( IsContextConnection )
974
- {
975
- throw SQL . NotAvailableOnContextConnection ( ) ;
976
- }
977
-
978
938
// If not supplied by the user, the default value is the MachineName
979
939
// Note: In Longhorn you'll be able to rename a machine without
980
940
// rebooting. Therefore, don't cache this machine name.
@@ -1086,11 +1046,6 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionStringAndSqlCredential
1086
1046
{
1087
1047
throw ADP . InvalidMixedUsageOfSecureCredentialAndIntegratedSecurity ( ) ;
1088
1048
}
1089
-
1090
- if ( UsesContextConnection ( connectionOptions ) )
1091
- {
1092
- throw ADP . InvalidMixedArgumentOfSecureCredentialAndContextConnection ( ) ;
1093
- }
1094
1049
}
1095
1050
1096
1051
// CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessToken: check if the usage of AccessToken has any conflict
@@ -1109,11 +1064,6 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessToken(S
1109
1064
throw ADP . InvalidMixedUsageOfAccessTokenAndIntegratedSecurity ( ) ;
1110
1065
}
1111
1066
1112
- if ( UsesContextConnection ( connectionOptions ) )
1113
- {
1114
- throw ADP . InvalidMixedUsageOfAccessTokenAndContextConnection ( ) ;
1115
- }
1116
-
1117
1067
if ( UsesAuthentication ( connectionOptions ) )
1118
1068
{
1119
1069
throw ADP . InvalidMixedUsageOfAccessTokenAndAuthentication ( ) ;
@@ -1328,10 +1278,6 @@ public static void ClearPool(SqlConnection connection)
1328
1278
if ( connectionOptions != null )
1329
1279
{
1330
1280
connectionOptions . DemandPermission ( ) ;
1331
- if ( connection . IsContextConnection )
1332
- {
1333
- throw SQL . NotAvailableOnContextConnection ( ) ;
1334
- }
1335
1281
SqlConnectionFactory . SingletonInstance . ClearPool ( connection ) ;
1336
1282
}
1337
1283
}
@@ -1446,21 +1392,12 @@ private void DisposeMe(bool disposing)
1446
1392
}
1447
1393
1448
1394
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/EnlistDistributedTransaction/*' />
1449
- public void EnlistDistributedTransaction ( System . EnterpriseServices . ITransaction transaction )
1450
- {
1451
- if ( IsContextConnection )
1452
- {
1453
- throw SQL . NotAvailableOnContextConnection ( ) ;
1454
- }
1455
-
1395
+ public void EnlistDistributedTransaction ( System . EnterpriseServices . ITransaction transaction ) =>
1456
1396
EnlistDistributedTransactionHelper ( transaction ) ;
1457
- }
1458
1397
1459
1398
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/Open/*' />
1460
- public override void Open ( )
1461
- {
1399
+ public override void Open ( ) =>
1462
1400
Open ( SqlConnectionOverrides . None ) ;
1463
- }
1464
1401
1465
1402
private bool TryOpenWithRetry ( TaskCompletionSource < DbConnectionInternal > retry , SqlConnectionOverrides overrides )
1466
1403
=> RetryLogicProvider . Execute ( this , ( ) => TryOpen ( retry , overrides ) ) ;
@@ -1773,13 +1710,6 @@ private Task InternalOpenAsync(SqlConnectionOverrides overrides, CancellationTok
1773
1710
return result . Task ;
1774
1711
}
1775
1712
1776
- if ( IsContextConnection )
1777
- {
1778
- // Async not supported on Context Connections
1779
- result . SetException ( ADP . ExceptionWithStackTrace ( SQL . NotAvailableOnContextConnection ( ) ) ) ;
1780
- return result . Task ;
1781
- }
1782
-
1783
1713
bool completed ;
1784
1714
1785
1715
try
@@ -2275,12 +2205,8 @@ public static void ChangePassword(string connectionString, string newPassword)
2275
2205
{
2276
2206
throw SQL . ChangePasswordUseOfUnallowedKey ( SqlConnectionString . KEY . AttachDBFilename ) ;
2277
2207
}
2278
- if ( connectionOptions . ContextConnection )
2279
- {
2280
- throw SQL . ChangePasswordUseOfUnallowedKey ( SqlConnectionString . KEY . Context_Connection ) ;
2281
- }
2282
2208
2283
- System . Security . PermissionSet permissionSet = connectionOptions . CreatePermissionSet ( ) ;
2209
+ PermissionSet permissionSet = connectionOptions . CreatePermissionSet ( ) ;
2284
2210
permissionSet . Demand ( ) ;
2285
2211
2286
2212
ChangePassword ( connectionString , connectionOptions , null , newPassword , null ) ;
@@ -2340,12 +2266,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent
2340
2266
throw SQL . ChangePasswordUseOfUnallowedKey ( SqlConnectionString . KEY . AttachDBFilename ) ;
2341
2267
}
2342
2268
2343
- if ( connectionOptions . ContextConnection )
2344
- {
2345
- throw SQL . ChangePasswordUseOfUnallowedKey ( SqlConnectionString . KEY . Context_Connection ) ;
2346
- }
2347
-
2348
- System . Security . PermissionSet permissionSet = connectionOptions . CreatePermissionSet ( ) ;
2269
+ PermissionSet permissionSet = connectionOptions . CreatePermissionSet ( ) ;
2349
2270
permissionSet . Demand ( ) ;
2350
2271
2351
2272
ChangePassword ( connectionString , connectionOptions , credential , null , newSecurePassword ) ;
@@ -2419,11 +2340,6 @@ internal Task<T> RegisterForConnectionCloseNotification<T>(Task<T> outerTask, ob
2419
2340
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/ResetStatistics/*' />
2420
2341
public void ResetStatistics ( )
2421
2342
{
2422
- if ( IsContextConnection )
2423
- {
2424
- throw SQL . NotAvailableOnContextConnection ( ) ;
2425
- }
2426
-
2427
2343
if ( Statistics != null )
2428
2344
{
2429
2345
Statistics . Reset ( ) ;
@@ -2438,11 +2354,6 @@ public void ResetStatistics()
2438
2354
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/RetrieveStatistics/*' />
2439
2355
public IDictionary RetrieveStatistics ( )
2440
2356
{
2441
- if ( IsContextConnection )
2442
- {
2443
- throw SQL . NotAvailableOnContextConnection ( ) ;
2444
- }
2445
-
2446
2357
if ( Statistics != null )
2447
2358
{
2448
2359
UpdateStatistics ( ) ;
0 commit comments