本文整理汇总了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);
}
示例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]);
}
示例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);
}
示例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;
}
示例5: CreateOptions
private static DbContextOptions CreateOptions(Action<EntityServicesBuilder> builderAction)
{
IDbContextOptionsExtensions options = new DbContextOptions();
options.AddOrUpdateExtension<FakeDbContextOptionsExtension>(e => e.BuilderActions.Add(builderAction));
return (DbContextOptions)options;
}