|
6 | 6 | using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
|
7 | 7 | using Microsoft.EntityFrameworkCore.Design.Internal;
|
8 | 8 | using Microsoft.EntityFrameworkCore.Internal;
|
9 |
| -using Microsoft.EntityFrameworkCore.Metadata; |
10 | 9 | using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
11 | 10 | using Microsoft.EntityFrameworkCore.Query.Internal;
|
12 | 11 |
|
@@ -1498,8 +1497,10 @@ private void
|
1498 | 1497 | var variableName = parameters.TargetName;
|
1499 | 1498 | var mainBuilder = parameters.MainBuilder;
|
1500 | 1499 | var unsafeAccessors = new HashSet<string>();
|
| 1500 | + var isOnComplexCollection = property.DeclaringType is IReadOnlyComplexType complexType && complexType.ComplexProperty.IsCollection; |
1501 | 1501 |
|
1502 | 1502 | if (!property.IsShadowProperty()
|
| 1503 | + && !isOnComplexCollection |
1503 | 1504 | && property is not IServiceProperty) // Service properties don't use property accessors
|
1504 | 1505 | {
|
1505 | 1506 | ClrPropertyGetterFactory.Instance.Create(
|
@@ -1559,7 +1560,8 @@ private void
|
1559 | 1560 | .DecrementIndent();
|
1560 | 1561 | }
|
1561 | 1562 |
|
1562 |
| - if (property is not IServiceProperty) |
| 1563 | + if (property is not IServiceProperty |
| 1564 | + && !isOnComplexCollection) |
1563 | 1565 | {
|
1564 | 1566 | PropertyAccessorsFactory.Instance.Create(
|
1565 | 1567 | property,
|
@@ -2783,6 +2785,21 @@ private void CreateAnnotations(
|
2783 | 2785 | mainBuilder.AppendLine(";");
|
2784 | 2786 | }
|
2785 | 2787 |
|
| 2788 | + foreach (var navigation in entityType.GetSkipNavigations()) |
| 2789 | + { |
| 2790 | + var variableName = _code.Identifier(navigation.Name, navigation, parameters.ScopeObjects, capitalize: false); |
| 2791 | + |
| 2792 | + mainBuilder |
| 2793 | + .Append($"var {variableName} = ") |
| 2794 | + .Append($"{parameters.TargetName}.FindSkipNavigation({_code.Literal(navigation.Name)})"); |
| 2795 | + if (nullable) |
| 2796 | + { |
| 2797 | + mainBuilder.Append("!"); |
| 2798 | + } |
| 2799 | + |
| 2800 | + mainBuilder.AppendLine(";"); |
| 2801 | + } |
| 2802 | + |
2786 | 2803 | var runtimeType = (IRuntimeEntityType)entityType;
|
2787 | 2804 | var unsafeAccessors = new HashSet<string>();
|
2788 | 2805 |
|
@@ -2859,17 +2876,18 @@ private void CreateAnnotations(
|
2859 | 2876 | .DecrementIndent();
|
2860 | 2877 |
|
2861 | 2878 | AddNamespace(typeof(PropertyCounts), parameters.Namespaces);
|
2862 |
| - var counts = runtimeType.Counts; |
| 2879 | + var counts = runtimeType.CalculateCounts(); |
2863 | 2880 | mainBuilder
|
2864 |
| - .Append(parameters.TargetName).AppendLine(".Counts = new PropertyCounts(") |
| 2881 | + .Append(parameters.TargetName).AppendLine(".SetCounts(new PropertyCounts(") |
2865 | 2882 | .IncrementIndent()
|
2866 | 2883 | .Append("propertyCount: ").Append(_code.Literal(counts.PropertyCount)).AppendLine(",")
|
2867 | 2884 | .Append("navigationCount: ").Append(_code.Literal(counts.NavigationCount)).AppendLine(",")
|
2868 | 2885 | .Append("complexPropertyCount: ").Append(_code.Literal(counts.ComplexPropertyCount)).AppendLine(",")
|
| 2886 | + .Append("complexCollectionCount: ").Append(_code.Literal(counts.ComplexCollectionCount)).AppendLine(",") |
2869 | 2887 | .Append("originalValueCount: ").Append(_code.Literal(counts.OriginalValueCount)).AppendLine(",")
|
2870 | 2888 | .Append("shadowCount: ").Append(_code.Literal(counts.ShadowCount)).AppendLine(",")
|
2871 | 2889 | .Append("relationshipCount: ").Append(_code.Literal(counts.RelationshipCount)).AppendLine(",")
|
2872 |
| - .Append("storeGeneratedCount: ").Append(_code.Literal(counts.StoreGeneratedCount)).AppendLine(");") |
| 2890 | + .Append("storeGeneratedCount: ").Append(_code.Literal(counts.StoreGeneratedCount)).AppendLine("));") |
2873 | 2891 | .DecrementIndent();
|
2874 | 2892 |
|
2875 | 2893 | Check.DebugAssert(
|
|
0 commit comments