• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Interception.DbConnectionInterceptionContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Data.Entity.Infrastructure.Interception.DbConnectionInterceptionContext的典型用法代码示例。如果您正苦于以下问题:C# DbConnectionInterceptionContext类的具体用法?C# DbConnectionInterceptionContext怎么用?C# DbConnectionInterceptionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DbConnectionInterceptionContext类属于System.Data.Entity.Infrastructure.Interception命名空间,在下文中一共展示了DbConnectionInterceptionContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Cloning_the_interception_context_preserves_contextual_information_but_not_mutable_state

            public void Cloning_the_interception_context_preserves_contextual_information_but_not_mutable_state()
            {
                var objectContext = new ObjectContext();
                var dbContext = DbContextMockHelper.CreateDbContext(objectContext);

                var interceptionContext = new DbConnectionInterceptionContext<int>();
                interceptionContext.Exception = new Exception("Cheez Whiz");
                interceptionContext.Result = 23;
                interceptionContext.UserState = "Red Windsor";

                interceptionContext = interceptionContext
                    .WithDbContext(dbContext)
                    .WithObjectContext(objectContext)
                    .AsAsync();

                Assert.Equal(new[] { objectContext }, interceptionContext.ObjectContexts);
                Assert.Equal(new[] { dbContext }, interceptionContext.DbContexts);
                Assert.True(interceptionContext.IsAsync);

                Assert.Equal(0, interceptionContext.Result);
                Assert.Equal(0, interceptionContext.OriginalResult);
                Assert.Null(interceptionContext.Exception);
                Assert.Null(interceptionContext.OriginalException);
                Assert.False(interceptionContext.IsExecutionSuppressed);
                Assert.Null(interceptionContext.UserState);
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:26,代码来源:DbConnectionInterceptionContextTests.cs


示例2: Closing

        public void Closing(DbConnection connection, DbConnectionInterceptionContext interceptionContext)
        {
            var stats = ((SqlConnection)connection).RetrieveStatistics();
            var bytesReceived = stats["BytesReceived"];

            // TODO: Observe the database response size using the monitoring system of your choice.
        }
开发者ID:smartpcr,项目名称:performance-optimization,代码行数:7,代码来源:ConnectionInterceptor.cs


示例3: Initially_has_no_state

            public void Initially_has_no_state()
            {
                var interceptionContext = new DbConnectionInterceptionContext<int>();

                Assert.Empty(interceptionContext.DbContexts);
                Assert.Null(interceptionContext.Exception);
                Assert.False(interceptionContext.IsAsync);
                Assert.False(interceptionContext.IsExecutionSuppressed);
                Assert.Empty(interceptionContext.ObjectContexts);
                Assert.Null(interceptionContext.OriginalException);
                Assert.Equal(0, interceptionContext.OriginalResult);
                Assert.Equal(0, interceptionContext.Result);
                Assert.Equal((TaskStatus)0, interceptionContext.TaskStatus);
                Assert.Null(interceptionContext.UserState);
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:15,代码来源:DbConnectionInterceptionContextTests.cs


示例4: Dispose_executes_operation_and_dispatches_to_interceptors

        public void Dispose_executes_operation_and_dispatches_to_interceptors()
        {
            var mockConnection = new Mock<DbConnection>();
            var mockInterceptor = new Mock<IDbConnectionInterceptor>();
            var dispatcher = new DbConnectionDispatcher();
            var internalDispatcher = dispatcher.InternalDispatcher;
            internalDispatcher.Add(mockInterceptor.Object);

            var interceptionContext = new DbConnectionInterceptionContext();
            dispatcher.Dispose(mockConnection.Object, interceptionContext);

            mockConnection.Protected().Verify("Dispose", Times.Once(), ItExpr.IsAny<bool>());
            mockInterceptor.Verify(m => m.Disposing(mockConnection.Object, It.IsAny<DbConnectionInterceptionContext>()), Times.Once());
            mockInterceptor.Verify(m => m.Disposed(mockConnection.Object, It.IsAny<DbConnectionInterceptionContext>()), Times.Once());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:15,代码来源:DbConnectionDispatcherTests.cs


示例5: OpenAsync_executes_operation_and_dispatches_to_interceptors

        public void OpenAsync_executes_operation_and_dispatches_to_interceptors()
        {
            var mockConnection = new Mock<DbConnection>();
            mockConnection.Setup(m => m.OpenAsync(It.IsAny<CancellationToken>())).Returns(() => Task.FromResult(true));
            var mockInterceptor = new Mock<IDbConnectionInterceptor>();
            var dispatcher = new DbConnectionDispatcher();
            var internalDispatcher = dispatcher.InternalDispatcher;
            internalDispatcher.Add(mockInterceptor.Object);

            var interceptionContext = new DbConnectionInterceptionContext();
            dispatcher.OpenAsync(mockConnection.Object, interceptionContext, CancellationToken.None).Wait();

            mockConnection.Verify(m => m.OpenAsync(CancellationToken.None), Times.Once());
            mockInterceptor.Verify(m => m.Opening(mockConnection.Object, It.IsAny<DbConnectionInterceptionContext>()), Times.Once());
            mockInterceptor.Verify(m => m.Opened(mockConnection.Object, It.IsAny<DbConnectionInterceptionContext>()), Times.Once());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:16,代码来源:DbConnectionDispatcherTests.cs


示例6: Disposed

 public void Disposed(DbConnection connection, DbConnectionInterceptionContext interceptionContext)
 {
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:3,代码来源:ClonedObjectContextTests.cs


示例7: Opened_logs_canceled

 public void Opened_logs_canceled()
 {
     var writer = new StringWriter();
     var interceptionContext = new DbConnectionInterceptionContext().AsAsync();
     interceptionContext.MutableData.TaskStatus = TaskStatus.Canceled;
     new DatabaseLogFormatter(writer.Write).Opened(new Mock<DbConnection>().Object, interceptionContext);
     Assert.True(_resourceVerifier.IsMatch("ConnectionOpenCanceledLog", GetSingleLine(writer), new AnyValueParameter(), ""));
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:DatabaseLogFormatterTests.cs


示例8: ConnectionTimeoutGot

 public void ConnectionTimeoutGot(DbConnection connection, DbConnectionInterceptionContext<int> interceptionContext)
 {
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:3,代码来源:ClonedObjectContextTests.cs


示例9: DataSourceGot

 public void DataSourceGot(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)
 {
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:3,代码来源:ClonedObjectContextTests.cs


示例10: StateGetting

 /// <summary>
 /// 在获取数据库连接状态动作执行前瞬间触发。
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="interceptionContext"></param>
 public virtual void StateGetting(DbConnection connection, DbConnectionInterceptionContext<ConnectionState> interceptionContext)
 {
 }
开发者ID:kylin589,项目名称:NDF.Infrastructure,代码行数:8,代码来源:NullDbConnectionInterceptor.cs


示例11: Closing

 public void Closing(DbConnection connection, DbConnectionInterceptionContext interceptionContext)
 {
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:3,代码来源:ClonedObjectContextTests.cs


示例12: Opening

 /// <summary>
 /// 在打开数据库连接动作执行前瞬间触发。
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="interceptionContext"></param>
 public virtual void Opening(DbConnection connection, DbConnectionInterceptionContext interceptionContext)
 {
 }
开发者ID:kylin589,项目名称:NDF.Infrastructure,代码行数:8,代码来源:NullDbConnectionInterceptor.cs


示例13: ServerVersionGetting

 /// <summary>
 /// 在获取数据库版本信息动作执行前瞬间触发。
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="interceptionContext"></param>
 public virtual void ServerVersionGetting(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)
 {
 }
开发者ID:kylin589,项目名称:NDF.Infrastructure,代码行数:8,代码来源:NullDbConnectionInterceptor.cs


示例14: DatabaseGot

 /// <summary>
 /// 在获取数据库名称动作完成后瞬间触发。
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="interceptionContext"></param>
 public virtual void DatabaseGot(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)
 {
 }
开发者ID:kylin589,项目名称:NDF.Infrastructure,代码行数:8,代码来源:NullDbConnectionInterceptor.cs


示例15: DataSourceGetting

 /// <summary>
 /// 在获取 数据源服务器名称/IP 名称动作执行前瞬间触发。
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="interceptionContext"></param>
 public virtual void DataSourceGetting(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)
 {
 }
开发者ID:kylin589,项目名称:NDF.Infrastructure,代码行数:8,代码来源:NullDbConnectionInterceptor.cs


示例16: ConnectionTimeoutGetting

 /// <summary>
 /// 在获取数据库连接超时时间动作执行前瞬间触发。
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="interceptionContext"></param>
 public virtual void ConnectionTimeoutGetting(DbConnection connection, DbConnectionInterceptionContext<int> interceptionContext)
 {
 }
开发者ID:kylin589,项目名称:NDF.Infrastructure,代码行数:8,代码来源:NullDbConnectionInterceptor.cs


示例17: Open_executes_operation_and_dispatches_to_interceptors

        public void Open_executes_operation_and_dispatches_to_interceptors()
        {
            var mockConnection = new Mock<DbConnection>();
            var mockInterceptor = new Mock<IDbConnectionInterceptor>();
            var dispatcher = new DbConnectionDispatcher();
            var internalDispatcher = dispatcher.InternalDispatcher;
            internalDispatcher.Add(mockInterceptor.Object);

            var interceptionContext = new DbConnectionInterceptionContext();
            dispatcher.Open(mockConnection.Object, interceptionContext);

            mockConnection.Verify(m => m.Open(), Times.Once());
            mockInterceptor.Verify(m => m.Opening(mockConnection.Object, It.IsAny<DbConnectionInterceptionContext>()), Times.Once());
            mockInterceptor.Verify(m => m.Opened(mockConnection.Object, It.IsAny<DbConnectionInterceptionContext>()), Times.Once());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:15,代码来源:DbConnectionDispatcherTests.cs


示例18: Closed

 /// <summary>
 /// 在关闭数据库连接动作完成后瞬间触发。
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="interceptionContext"></param>
 public virtual void Closed(DbConnection connection, DbConnectionInterceptionContext interceptionContext)
 {
 }
开发者ID:kylin589,项目名称:NDF.Infrastructure,代码行数:8,代码来源:NullDbConnectionInterceptor.cs


示例19: Closed

 public void Closed(DbConnection connection,
                    DbConnectionInterceptionContext interceptionContext)
 {
     var context = EFProfilerContextProvider.GetLoggedDbConnection(connection, interceptionContext);
     _profiler.ConnectionClosed(connection, context);
 }
开发者ID:yao-yi,项目名称:DNTProfiler,代码行数:6,代码来源:DatabaseInterceptor.cs


示例20: ConnectionStringGetting

 /// <summary>
 /// 在获取数据库连接字符串动作执行前瞬间触发。
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="interceptionContext"></param>
 public virtual void ConnectionStringGetting(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)
 {
 }
开发者ID:kylin589,项目名称:NDF.Infrastructure,代码行数:8,代码来源:NullDbConnectionInterceptor.cs



注:本文中的System.Data.Entity.Infrastructure.Interception.DbConnectionInterceptionContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Internal.LazyInternalConnection类代码示例发布时间:2022-05-26
下一篇:
C# Interception.DbCommandInterceptionContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap