-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add owned entity types support to more places in query
Record the EntityType when visiting existing JoinClause Update QuerySourceMapping when cloning Add provider-specific model building extensions Add more query tests for owned entity types
- Loading branch information
1 parent
1c8eeb1
commit c52548b
Showing
41 changed files
with
2,380 additions
and
597 deletions.
There are no files selected for viewing
10 changes: 0 additions & 10 deletions
10
src/EFCore.Relational.Specification.Tests/ComplexNavigationsQueryRelationalFixture.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
src/EFCore.Specification.Tests/ComplexNavigationsOwnedQueryFixtureBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
// 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. | ||
|
||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.EntityFrameworkCore.Specification.Tests.TestModels.ComplexNavigationsModel; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Specification.Tests | ||
{ | ||
public abstract class ComplexNavigationsOwnedQueryFixtureBase<TTestStore> : ComplexNavigationsQueryFixtureBase<TTestStore> | ||
where TTestStore : TestStore | ||
{ | ||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Level1>().Property(e => e.Id).ValueGeneratedNever(); | ||
|
||
modelBuilder.Entity<Level1>() | ||
.Ignore(e => e.OneToOne_Optional_Self) | ||
.Ignore(e => e.OneToMany_Required_Self) | ||
.Ignore(e => e.OneToMany_Required_Self_Inverse) | ||
.Ignore(e => e.OneToMany_Optional_Self) | ||
.Ignore(e => e.OneToMany_Optional_Self_Inverse) | ||
.Ignore(e => e.OneToMany_Required) | ||
.Ignore(e => e.OneToMany_Optional) | ||
.OwnsOne(e => e.OneToOne_Required_PK, Configure); | ||
|
||
modelBuilder.Entity<ComplexNavigationField>().HasKey(e => e.Name); | ||
modelBuilder.Entity<ComplexNavigationString>().HasKey(e => e.DefaultText); | ||
modelBuilder.Entity<ComplexNavigationGlobalization>().HasKey(e => e.Text); | ||
modelBuilder.Entity<ComplexNavigationLanguage>().HasKey(e => e.Name); | ||
|
||
modelBuilder.Entity<ComplexNavigationField>().HasOne(f => f.Label); | ||
modelBuilder.Entity<ComplexNavigationField>().HasOne(f => f.Placeholder); | ||
|
||
modelBuilder.Entity<ComplexNavigationString>().HasMany(m => m.Globalizations); | ||
|
||
modelBuilder.Entity<ComplexNavigationGlobalization>().HasOne(g => g.Language); | ||
} | ||
|
||
protected virtual void Configure(ReferenceOwnershipBuilder<Level1, Level2> l2) | ||
{ | ||
l2.Ignore(e => e.OneToOne_Optional_Self) | ||
.Ignore(e => e.OneToMany_Required_Self) | ||
.Ignore(e => e.OneToMany_Required_Self_Inverse) | ||
.Ignore(e => e.OneToMany_Optional_Self) | ||
.Ignore(e => e.OneToMany_Optional_Self_Inverse) | ||
.Ignore(e => e.OneToMany_Required) | ||
.Ignore(e => e.OneToMany_Required_Inverse) | ||
.Ignore(e => e.OneToMany_Optional) | ||
.Ignore(e => e.OneToMany_Optional_Inverse); | ||
|
||
l2.HasForeignKey(e => e.Id) | ||
.OnDelete(DeleteBehavior.Restrict); | ||
|
||
l2.Property(e => e.Id).ValueGeneratedNever(); | ||
|
||
l2.HasOne(e => e.OneToOne_Required_PK_Inverse) | ||
.WithOne(e => e.OneToOne_Required_PK); | ||
|
||
l2.HasOne(e => e.OneToOne_Optional_PK_Inverse) | ||
.WithOne(e => e.OneToOne_Optional_PK) | ||
.HasPrincipalKey<Level1>(e => e.Id) | ||
.IsRequired(false); | ||
|
||
l2.HasOne(e => e.OneToOne_Required_FK_Inverse) | ||
.WithOne(e => e.OneToOne_Required_FK) | ||
.HasForeignKey<Level2>(e => e.Level1_Required_Id) | ||
.IsRequired() | ||
.OnDelete(DeleteBehavior.Restrict); | ||
|
||
l2.HasOne(e => e.OneToOne_Optional_FK_Inverse) | ||
.WithOne(e => e.OneToOne_Optional_FK) | ||
.HasForeignKey<Level2>(e => e.Level1_Optional_Id) | ||
.IsRequired(false); | ||
|
||
l2.OwnsOne(e => e.OneToOne_Required_PK, Configure); | ||
} | ||
|
||
protected virtual void Configure(ReferenceOwnershipBuilder<Level2, Level3> l3) | ||
{ | ||
l3.Ignore(e => e.OneToOne_Optional_Self) | ||
.Ignore(e => e.OneToMany_Required_Self) | ||
.Ignore(e => e.OneToMany_Required_Self_Inverse) | ||
.Ignore(e => e.OneToMany_Optional_Self) | ||
.Ignore(e => e.OneToMany_Optional_Self_Inverse) | ||
.Ignore(e => e.OneToMany_Required) | ||
.Ignore(e => e.OneToMany_Required_Inverse) | ||
.Ignore(e => e.OneToMany_Optional) | ||
.Ignore(e => e.OneToMany_Optional_Inverse); | ||
|
||
l3.HasForeignKey(e => e.Id) | ||
.OnDelete(DeleteBehavior.Restrict); | ||
|
||
l3.Property(e => e.Id).ValueGeneratedNever(); | ||
|
||
l3.HasOne(e => e.OneToOne_Required_PK_Inverse) | ||
.WithOne(e => e.OneToOne_Required_PK); | ||
|
||
l3.HasOne(e => e.OneToOne_Optional_PK_Inverse) | ||
.WithOne(e => e.OneToOne_Optional_PK) | ||
.HasPrincipalKey<Level2>(e => e.Id) | ||
.IsRequired(false); | ||
|
||
l3.HasOne(e => e.OneToOne_Required_FK_Inverse) | ||
.WithOne(e => e.OneToOne_Required_FK) | ||
.HasForeignKey<Level3>(e => e.Level2_Required_Id) | ||
.IsRequired() | ||
.OnDelete(DeleteBehavior.Restrict); | ||
|
||
l3.HasOne(e => e.OneToOne_Optional_FK_Inverse) | ||
.WithOne(e => e.OneToOne_Optional_FK) | ||
.HasForeignKey<Level3>(e => e.Level2_Optional_Id) | ||
.IsRequired(false); | ||
|
||
l3.OwnsOne(e => e.OneToOne_Required_PK, Configure); | ||
} | ||
|
||
protected virtual void Configure(ReferenceOwnershipBuilder<Level3, Level4> l4) | ||
{ | ||
l4.Ignore(e => e.OneToOne_Optional_Self) | ||
.Ignore(e => e.OneToMany_Required_Self) | ||
.Ignore(e => e.OneToMany_Required_Self_Inverse) | ||
.Ignore(e => e.OneToMany_Optional_Self) | ||
.Ignore(e => e.OneToMany_Optional_Self_Inverse) | ||
.Ignore(e => e.OneToMany_Required_Inverse) | ||
.Ignore(e => e.OneToMany_Optional_Inverse); | ||
|
||
l4.HasForeignKey(e => e.Id) | ||
.OnDelete(DeleteBehavior.Restrict); | ||
|
||
l4.Property(e => e.Id).ValueGeneratedNever(); | ||
|
||
l4.HasOne(e => e.OneToOne_Required_PK_Inverse) | ||
.WithOne(e => e.OneToOne_Required_PK); | ||
|
||
l4.HasOne(e => e.OneToOne_Optional_PK_Inverse) | ||
.WithOne(e => e.OneToOne_Optional_PK) | ||
.HasPrincipalKey<Level3>() | ||
.IsRequired(false); | ||
|
||
l4.HasOne(e => e.OneToOne_Required_FK_Inverse) | ||
.WithOne(e => e.OneToOne_Required_FK) | ||
.HasForeignKey<Level4>(e => e.Level3_Required_Id) | ||
.IsRequired() | ||
.OnDelete(DeleteBehavior.Restrict); | ||
|
||
l4.HasOne(e => e.OneToOne_Optional_FK_Inverse) | ||
.WithOne(e => e.OneToOne_Optional_FK) | ||
.HasForeignKey<Level4>(e => e.Level3_Optional_Id) | ||
.IsRequired(false); | ||
} | ||
} | ||
} |
Oops, something went wrong.