Skip to content

Commit

Permalink
Rename IncludeRootDiscriminatorInJsonId to HasRootDiscriminatorInJson…
Browse files Browse the repository at this point in the history
…Id (#34717)
  • Loading branch information
roji authored Sep 20, 2024
1 parent 59d16b6 commit a89537e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public static EntityTypeBuilder HasDiscriminatorInJsonId(
/// <see langword="null" /> to revert to the default setting.
/// </param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
public static EntityTypeBuilder IncludeRootDiscriminatorInJsonId(
public static EntityTypeBuilder HasRootDiscriminatorInJsonId(
this EntityTypeBuilder entityTypeBuilder,
bool? includeDiscriminator = true)
{
Expand Down Expand Up @@ -578,11 +578,11 @@ public static EntityTypeBuilder<TEntity> HasDiscriminatorInJsonId<TEntity>(
/// <see langword="null" /> to revert to the default setting.
/// </param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
public static EntityTypeBuilder<TEntity> IncludeRootDiscriminatorInJsonId<TEntity>(
public static EntityTypeBuilder<TEntity> HasRootDiscriminatorInJsonId<TEntity>(
this EntityTypeBuilder<TEntity> entityTypeBuilder,
bool? includeDiscriminator = true)
where TEntity : class
=> (EntityTypeBuilder<TEntity>)IncludeRootDiscriminatorInJsonId((EntityTypeBuilder)entityTypeBuilder, includeDiscriminator);
=> (EntityTypeBuilder<TEntity>)HasRootDiscriminatorInJsonId((EntityTypeBuilder)entityTypeBuilder, includeDiscriminator);

/// <summary>
/// Includes the discriminator value of the entity type in the JSON "id" value. This was the default behavior before EF Core 9.
Expand Down Expand Up @@ -633,12 +633,12 @@ public static EntityTypeBuilder<TEntity> IncludeRootDiscriminatorInJsonId<TEntit
/// </param>
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns>The same builder instance if the configuration was applied, <see langword="null" /> otherwise.</returns>
public static IConventionEntityTypeBuilder? IncludeRootDiscriminatorInJsonId(
public static IConventionEntityTypeBuilder? HasRootDiscriminatorInJsonId(
this IConventionEntityTypeBuilder entityTypeBuilder,
bool? includeDiscriminator,
bool fromDataAnnotation = false)
{
if (!entityTypeBuilder.CanSetIncludeRootDiscriminatorInJsonId(includeDiscriminator, fromDataAnnotation))
if (!entityTypeBuilder.CanSetRootDiscriminatorInJsonId(includeDiscriminator, fromDataAnnotation))
{
return null;
}
Expand Down Expand Up @@ -699,7 +699,7 @@ public static bool CanSetDiscriminatorInJsonId(
/// </param>
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns><see langword="true" /> if the configuration can be applied.</returns>
public static bool CanSetIncludeRootDiscriminatorInJsonId(
public static bool CanSetRootDiscriminatorInJsonId(
this IConventionEntityTypeBuilder entityTypeBuilder,
bool? includeDiscriminator,
bool fromDataAnnotation = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static ModelBuilder HasDiscriminatorInJsonIds(
/// <see langword="null" /> to revert to the default setting.
/// </param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
public static ModelBuilder IncludeRootDiscriminatorInJsonId(
public static ModelBuilder HasRootDiscriminatorInJsonId(
this ModelBuilder modelBuilder,
bool? includeDiscriminator = true)
{
Expand Down
6 changes: 3 additions & 3 deletions test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con

modelBuilder.Entity<IntKey>()
.ToContainer("Ints")
.IncludeRootDiscriminatorInJsonId();
.HasRootDiscriminatorInJsonId();

modelBuilder.Entity<NullableIntKey>()
.ToContainer("Ints")
.IncludeRootDiscriminatorInJsonId();
.HasRootDiscriminatorInJsonId();

modelBuilder.Entity<StringKey>()
.ToContainer("Strings");
Expand All @@ -475,7 +475,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con

modelBuilder.Entity<BaseType>()
.ToContainer("Base")
.IncludeRootDiscriminatorInJsonId();
.HasRootDiscriminatorInJsonId();

modelBuilder.Entity<ShadowKey>().ToContainer("ShadowKeys");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
{
base.OnModelCreating(modelBuilder, context);

modelBuilder.IncludeRootDiscriminatorInJsonId();
modelBuilder.HasRootDiscriminatorInJsonId();
}

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,32 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
modelBuilder.Entity<Employee>().ToContainer("Employees");

modelBuilder.Entity<Order>()
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.ToContainer("ProductsAndOrders");

modelBuilder.Entity<OrderDetail>()
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.ToContainer("ProductsAndOrders");

modelBuilder.Entity<Product>()
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.ToContainer("ProductsAndOrders");

modelBuilder.Entity<OrderQuery>()
.ToContainer("ProductsAndOrders")
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.HasDiscriminator<string>("$type").HasValue("Order");

modelBuilder
.Entity<ProductQuery>()
.ToContainer("ProductsAndOrders")
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.HasDiscriminator<string>("$type").HasValue("Product");

modelBuilder
.Entity<ProductView>()
.ToContainer("ProductsAndOrders")
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.HasDiscriminator<string>("$type").HasValue("ProductView");

modelBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
{
base.OnModelCreating(modelBuilder, context);

modelBuilder.IncludeRootDiscriminatorInJsonId();
modelBuilder.HasRootDiscriminatorInJsonId();
}
}
}

0 comments on commit a89537e

Please sign in to comment.