Skip to content

Commit

Permalink
Add IInMemoryDbContextOptionsBuilderInfrastructure
Browse files Browse the repository at this point in the history
This is the moral equivalent of IRelationalDbContextOptionsBuilderInfrastructure which lets extension methods access the core options builder.

Fixes #23669
  • Loading branch information
bricelam committed Jun 15, 2021
1 parent 954da6f commit b5915fb
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
public class CosmosDbContextOptionsBuilder
public class CosmosDbContextOptionsBuilder : ICosmosDbContextOptionsBuilderInfrastructure
{
private readonly DbContextOptionsBuilder _optionsBuilder;

Expand All @@ -36,6 +36,10 @@ public CosmosDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder)
_optionsBuilder = optionsBuilder;
}

/// <inheritdoc />
DbContextOptionsBuilder ICosmosDbContextOptionsBuilderInfrastructure.OptionsBuilder
=> _optionsBuilder;

/// <summary>
/// Configures the context to use the provided <see cref="IExecutionStrategy" />.
/// </summary>
Expand Down Expand Up @@ -120,7 +124,7 @@ public virtual CosmosDbContextOptionsBuilder MaxRequestsPerTcpConnection(int req
=> WithOption(e => e.WithMaxRequestsPerTcpConnection(Check.NotNull(requestLimit, nameof(requestLimit))));

/// <summary>
/// Sets the boolean to only return the headers and status code in the Cosmos DB response for write item operation
/// Sets the boolean to only return the headers and status code in the Cosmos DB response for write item operation
/// like Create, Upsert, Patch and Replace. Setting the option to false will cause the response to have a null resource.
/// This reduces networking and CPU load by not sending the resource back over the network and serializing it on the client.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace Microsoft.EntityFrameworkCore.Infrastructure
{
/// <summary>
/// Explicitly implemented by <see cref="CosmosDbContextOptionsBuilder" /> to hide
/// methods that are used by database provider extension methods but not intended to be called by application
/// developers.
/// </summary>
public interface ICosmosDbContextOptionsBuilderInfrastructure
{
/// <summary>
/// Gets the core options builder.
/// </summary>
DbContextOptionsBuilder OptionsBuilder { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace Microsoft.EntityFrameworkCore.Infrastructure
{
/// <summary>
/// Explicitly implemented by <see cref="InMemoryDbContextOptionsBuilder" /> to hide
/// methods that are used by database provider extension methods but not intended to be called by application
/// developers.
/// </summary>
public interface IInMemoryDbContextOptionsBuilderInfrastructure
{
/// <summary>
/// Gets the core options builder.
/// </summary>
DbContextOptionsBuilder OptionsBuilder { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure
/// and it is not designed to be directly constructed in your application code.
/// </para>
/// </summary>
public class InMemoryDbContextOptionsBuilder
public class InMemoryDbContextOptionsBuilder : IInMemoryDbContextOptionsBuilderInfrastructure
{
/// <summary>
/// Initializes a new instance of the <see cref="InMemoryDbContextOptionsBuilder" /> class.
Expand All @@ -37,6 +37,10 @@ public InMemoryDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder)
/// <returns> The cloned configuration. </returns>
protected virtual DbContextOptionsBuilder OptionsBuilder { get; }

/// <inheritdoc />
DbContextOptionsBuilder IInMemoryDbContextOptionsBuilderInfrastructure.OptionsBuilder
=> OptionsBuilder;

/// <summary>
/// <para>
/// Enables nullability check for all properties across all entities within the in-memory database.
Expand Down

0 comments on commit b5915fb

Please sign in to comment.