Skip to content

Commit 92c7cbb

Browse files
committed
React to PR feedback
1 parent 4baa198 commit 92c7cbb

6 files changed

Lines changed: 25 additions & 10 deletions

File tree

src/EFCore.Relational/Metadata/Internal/Table.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,9 @@ public virtual bool IsExcludedFromMigrations
147147
{
148148
IProperty => propertyBase.GetTableColumnMappings()
149149
.FirstOrDefault(cm => cm.TableMapping.Table == this)?.Column,
150-
INavigation nav when nav.TargetEntityType.GetContainerColumnName() is string containerName
151-
&& containerName.Length != 0
150+
INavigation nav when nav.TargetEntityType.GetContainerColumnName() is { Length: > 0 } containerName
152151
=> FindColumn(containerName),
153-
IComplexProperty cp when cp.ComplexType.GetContainerColumnName() is string containerName
154-
&& containerName.Length != 0
152+
IComplexProperty cp when cp.ComplexType.GetContainerColumnName() is { Length: > 0 } containerName
155153
=> FindColumn(containerName),
156154
_ => null
157155
};

src/EFCore.Relational/Metadata/Internal/TableBase.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ public override bool IsReadOnly
9494
{
9595
IProperty => propertyBase.GetDefaultColumnMappings()
9696
.FirstOrDefault(cm => cm.TableMapping.Table == this)?.Column,
97-
INavigation nav => FindColumn(nav.TargetEntityType.GetContainerColumnName()!),
98-
IComplexProperty cp => FindColumn(cp.ComplexType.GetContainerColumnName()!),
97+
INavigation nav when nav.TargetEntityType.GetContainerColumnName() is { Length: > 0 } containerName
98+
=> FindColumn(containerName),
99+
IComplexProperty cp when cp.ComplexType.GetContainerColumnName() is { Length: > 0 } containerName
100+
=> FindColumn(containerName),
99101
_ => null
100102
};
101103

src/EFCore/Infrastructure/JsonPath.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ public class JsonPath
2929
/// </param>
3030
public JsonPath(IReadOnlyList<JsonPathSegment> segments, int[] ordinals)
3131
{
32-
Check.DebugAssert(
33-
ordinals.Length == segments.Count(s => s.IsArray),
34-
"Ordinals count must match the number of array segments.");
32+
var arraySegmentCount = segments.Count(s => s.IsArray);
33+
if (ordinals.Length != arraySegmentCount)
34+
{
35+
throw new ArgumentException(
36+
CoreStrings.InvalidJsonPathOrdinalCount(ordinals.Length, arraySegmentCount),
37+
nameof(ordinals));
38+
}
3539

3640
Segments = segments;
3741
Ordinals = ordinals;

src/EFCore/Infrastructure/JsonPathSegment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure;
99
/// <remarks>
1010
/// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see> for more information and examples.
1111
/// </remarks>
12-
public readonly struct JsonPathSegment
12+
public sealed class JsonPathSegment
1313
{
1414
/// <summary>
1515
/// Creates a new <see cref="JsonPathSegment" /> for a named property.

src/EFCore/Properties/CoreStrings.Designer.cs

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/EFCore/Properties/CoreStrings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,9 @@
778778
<data name="InvalidIncludeExpression" xml:space="preserve">
779779
<value>The expression '{expression}' is invalid inside an 'Include' operation, since it does not represent a property access: 't =&gt; t.MyProperty'. To target navigations declared on derived types, use casting ('t =&gt; ((Derived)t).MyProperty') or the 'as' operator ('t =&gt; (t as Derived).MyProperty'). Collection navigation access can be filtered by composing Where, OrderBy(Descending), ThenBy(Descending), Skip or Take operations. For more information on including related data, see https://go.microsoft.com/fwlink/?LinkID=746393.</value>
780780
</data>
781+
<data name="InvalidJsonPathOrdinalCount" xml:space="preserve">
782+
<value>The number of ordinals provided ({ordinalsCount}) must match the number of array segments in the JSON path ({arraySegmentCount}).</value>
783+
</data>
781784
<data name="InvalidKeyValue" xml:space="preserve">
782785
<value>Unable to track an entity of type '{entityType}' because its primary key property '{keyProperty}' is null.</value>
783786
</data>

0 commit comments

Comments
 (0)