当前位置: 首页>>代码示例>>C#>>正文


C# DbContextOptions.AddOrUpdateExtension方法代码示例

本文整理汇总了C#中DbContextOptions.AddOrUpdateExtension方法的典型用法代码示例。如果您正苦于以下问题:C# DbContextOptions.AddOrUpdateExtension方法的具体用法?C# DbContextOptions.AddOrUpdateExtension怎么用?C# DbContextOptions.AddOrUpdateExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbContextOptions的用法示例。


在下文中一共展示了DbContextOptions.AddOrUpdateExtension方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_update_an_existing_extension

        public void Can_update_an_existing_extension()
        {
            IDbContextOptionsExtensions options = new DbContextOptions();

            options.AddOrUpdateExtension<FakeDbContextOptionsExtension1>(e => e.Something += "One");
            options.AddOrUpdateExtension<FakeDbContextOptionsExtension1>(e => e.Something += "Two");

            Assert.Equal("OneTwo", options.Extensions.OfType<FakeDbContextOptionsExtension1>().Single().Something);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:9,代码来源:DbContextOptionsTest.cs

示例2: Extensions_can_be_added_to_options

        public void Extensions_can_be_added_to_options()
        {
            IDbContextOptionsExtensions options = new DbContextOptions();

            options.AddOrUpdateExtension<FakeDbContextOptionsExtension1>(e => { });
            options.AddOrUpdateExtension<FakeDbContextOptionsExtension2>(e => { });

            Assert.Equal(2, options.Extensions.Count);
            Assert.IsType<FakeDbContextOptionsExtension1>(options.Extensions[0]);
            Assert.IsType<FakeDbContextOptionsExtension2>(options.Extensions[1]);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:11,代码来源:DbContextOptionsTest.cs

示例3: Is_configured_when_configuration_contains_associated_extension

        public void Is_configured_when_configuration_contains_associated_extension()
        {
            IDbContextOptionsExtensions options = new DbContextOptions();
            options.AddOrUpdateExtension<InMemoryOptionsExtension>(e => { });

            var configurationMock = new Mock<DbContextConfiguration>();
            configurationMock.Setup(m => m.ContextOptions).Returns(options);

            Assert.True(new InMemoryDataStoreSource(configurationMock.Object).IsConfigured);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:10,代码来源:InMemoryDataStoreSourceTest.cs

示例4: CreateConfiguration

        private static DbContextConfiguration CreateConfiguration(
            Action<FakeOptionsExtension1> configUpdater1,
            Action<FakeOptionsExtension2> configUpdater2 = null)
        {
            IDbContextOptionsExtensions contextOptions = new DbContextOptions();

            if (configUpdater1 != null)
            {
                contextOptions.AddOrUpdateExtension(configUpdater1);
            }

            if (configUpdater2 != null)
            {
                contextOptions.AddOrUpdateExtension(configUpdater2);
            }

            var contextConfigurationMock = new Mock<DbContextConfiguration>();
            contextConfigurationMock.Setup(m => m.ContextOptions).Returns(contextOptions);

            return contextConfigurationMock.Object;
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:21,代码来源:RelationalConnectionTest.cs

示例5: CreateOptions

 private static DbContextOptions CreateOptions(Action<EntityServicesBuilder> builderAction)
 {
     IDbContextOptionsExtensions options = new DbContextOptions();
     options.AddOrUpdateExtension<FakeDbContextOptionsExtension>(e => e.BuilderActions.Add(builderAction));
     return (DbContextOptions)options;
 }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:6,代码来源:ServiceProviderCacheTest.cs


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