-
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.
Finished work: - basic metadata, - property/navigation access translation, - materialization (entity, collection, with nesting) Remaining work: - validation, - migration, - update, - collections of primitives, - array access/operations (force non-tracking!) - some metadata fixes (e.g. using actual type mapping for properties mapped to json, rather than default mappings), flowing json type info (npgsql), - honoring json property name attribute for custom naming, - custom serialization (???), - lots of fixes, cleanups, documentation, - testing
- Loading branch information
Showing
50 changed files
with
2,611 additions
and
82 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
53 changes: 53 additions & 0 deletions
53
src/EFCore.Relational/Metadata/Conventions/RelationalMapToJsonConvention.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,53 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Metadata.Conventions | ||
{ | ||
/// <summary> | ||
/// TODO | ||
/// </summary> | ||
public class RelationalMapToJsonConvention : IEntityTypeAnnotationChangedConvention | ||
{ | ||
/// <summary> | ||
/// TODO | ||
/// </summary> | ||
public void ProcessEntityTypeAnnotationChanged( | ||
IConventionEntityTypeBuilder entityTypeBuilder, | ||
string name, | ||
IConventionAnnotation? annotation, | ||
IConventionAnnotation? oldAnnotation, | ||
IConventionContext<IConventionAnnotation> context) | ||
{ | ||
if (name == RelationalAnnotationNames.MapToJsonColumnName) | ||
{ | ||
// TODO: if json type name was specified (via attribute) propagate it here and add it as annotation on the entity itself | ||
// needed for postgres, since it has two json types | ||
var tableName = entityTypeBuilder.Metadata.GetTableName(); | ||
if (tableName == null) | ||
{ | ||
throw new InvalidOperationException("need table name"); | ||
} | ||
|
||
var jsonColumnName = annotation?.Value as string; | ||
if (!string.IsNullOrEmpty(jsonColumnName)) | ||
{ | ||
foreach (var navigation in entityTypeBuilder.Metadata.GetNavigations() | ||
.Where(n => n.ForeignKey.IsOwnership | ||
&& n.DeclaringEntityType == entityTypeBuilder.Metadata | ||
&& n.TargetEntityType.IsOwned())) | ||
{ | ||
var currentJsonColumnName = navigation.TargetEntityType.MappedToJsonColumnName(); | ||
if (currentJsonColumnName == null || currentJsonColumnName != jsonColumnName) | ||
{ | ||
navigation.TargetEntityType.SetAnnotation(RelationalAnnotationNames.MapToJsonColumnName, jsonColumnName); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// TODO: unwind everything | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.