@@ -892,6 +892,121 @@ private void LogConnectionError(
892
892
893
893
#endregion ConnectionError
894
894
895
+ #region ConnectionCanceled
896
+
897
+ /// <summary>
898
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
899
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
900
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
901
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
902
+ /// </summary>
903
+ public virtual void ConnectionCanceled (
904
+ IRelationalConnection connection ,
905
+ DateTimeOffset startTime ,
906
+ TimeSpan duration )
907
+ {
908
+ var definition = RelationalResources . LogConnectionCanceled ( this ) ;
909
+
910
+ LogConnectionCanceled ( connection , definition ) ;
911
+
912
+ if ( NeedsEventData < IDbConnectionInterceptor > (
913
+ definition , out var interceptor , out var diagnosticSourceEnabled , out var simpleLogEnabled ) )
914
+ {
915
+ var eventData = BroadcastConnectionCanceled (
916
+ connection ,
917
+ startTime ,
918
+ duration ,
919
+ async: false ,
920
+ definition ,
921
+ diagnosticSourceEnabled ,
922
+ simpleLogEnabled ) ;
923
+
924
+ interceptor ? . ConnectionCanceled ( connection . DbConnection , eventData ) ;
925
+ }
926
+ }
927
+
928
+ /// <summary>
929
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
930
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
931
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
932
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
933
+ /// </summary>
934
+ public virtual Task ConnectionCanceledAsync (
935
+ IRelationalConnection connection ,
936
+ DateTimeOffset startTime ,
937
+ TimeSpan duration ,
938
+ CancellationToken cancellationToken = default )
939
+ {
940
+ var definition = RelationalResources . LogConnectionCanceled ( this ) ;
941
+
942
+ LogConnectionCanceled ( connection , definition ) ;
943
+
944
+ if ( NeedsEventData < IDbConnectionInterceptor > (
945
+ definition , out var interceptor , out var diagnosticSourceEnabled , out var simpleLogEnabled ) )
946
+ {
947
+ var eventData = BroadcastConnectionCanceled (
948
+ connection ,
949
+ startTime ,
950
+ duration ,
951
+ async: true ,
952
+ definition ,
953
+ diagnosticSourceEnabled ,
954
+ simpleLogEnabled ) ;
955
+
956
+ interceptor ? . ConnectionCanceled ( connection . DbConnection , eventData ) ;
957
+ }
958
+
959
+ return Task . CompletedTask ;
960
+ }
961
+
962
+ private ConnectionEndEventData BroadcastConnectionCanceled (
963
+ IRelationalConnection connection ,
964
+ DateTimeOffset startTime ,
965
+ TimeSpan duration ,
966
+ bool async ,
967
+ EventDefinition < string , string > definition ,
968
+ bool diagnosticSourceEnabled ,
969
+ bool simpleLogEnabled )
970
+ {
971
+ var eventData = new ConnectionEndEventData (
972
+ definition ,
973
+ ConnectionCanceled ,
974
+ connection . DbConnection ,
975
+ connection . Context ,
976
+ connection . ConnectionId ,
977
+ async,
978
+ startTime ,
979
+ duration ) ;
980
+
981
+ DispatchEventData ( definition , eventData , diagnosticSourceEnabled , simpleLogEnabled ) ;
982
+
983
+ return eventData ;
984
+
985
+ static string ConnectionCanceled ( EventDefinitionBase definition , EventData payload )
986
+ {
987
+ var d = ( EventDefinition < string , string > ) definition ;
988
+ var p = ( ConnectionEndEventData ) payload ;
989
+ return d . GenerateMessage (
990
+ p . Connection . Database ,
991
+ p . Connection . DataSource ) ;
992
+ }
993
+ }
994
+
995
+ private void LogConnectionCanceled (
996
+ IRelationalConnection connection ,
997
+ EventDefinition < string , string > definition )
998
+ {
999
+ if ( ShouldLog ( definition ) )
1000
+ {
1001
+ definition . Log (
1002
+ this ,
1003
+ connection . DbConnection . Database ,
1004
+ connection . DbConnection . DataSource ) ;
1005
+ }
1006
+ }
1007
+
1008
+ #endregion ConnectionCanceled
1009
+
895
1010
#region ConnectionCreating
896
1011
897
1012
/// <summary>
0 commit comments