Skip to content

Commit cc13750

Browse files
authored
Fix parameter type for ComplexCollection and ComplexProperty entry methods (#37065)
Fixes #37064
1 parent 46842f5 commit cc13750

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/EFCore/ChangeTracking/ComplexElementEntry`.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public virtual ComplexPropertyEntry<TEntity, TNestedComplexProperty> ComplexProp
124124
/// </param>
125125
/// <returns>An object that exposes change tracking information and operations for the given property.</returns>
126126
public virtual ComplexCollectionEntry<TEntity, TElement> ComplexCollection<TElement>(
127-
Expression<Func<TEntity, IEnumerable<TElement>?>> propertyExpression)
127+
Expression<Func<TComplexProperty, IEnumerable<TElement>?>> propertyExpression)
128128
where TElement : notnull
129129
{
130130
Check.NotNull(propertyExpression, nameof(propertyExpression));

src/EFCore/ChangeTracking/ComplexPropertyEntry`.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public virtual ComplexPropertyEntry<TEntity, TNestedComplexProperty> ComplexProp
117117
/// </param>
118118
/// <returns>An object that exposes change tracking information and operations for the given property.</returns>
119119
public virtual ComplexCollectionEntry<TEntity, TElement> ComplexCollection<TElement>(
120-
Expression<Func<TEntity, IEnumerable<TElement>?>> propertyExpression)
120+
Expression<Func<TComplexProperty, IEnumerable<TElement>?>> propertyExpression)
121121
where TElement : notnull
122122
{
123123
Check.NotNull(propertyExpression, nameof(propertyExpression));

test/EFCore.Tests/ChangeTracking/Internal/InternalComplexEntryTest.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ public void DetectChanges_detects_changes_in_nested_complex_collections()
707707
{
708708
Items =
709709
[
710-
new NestedItem { Name = "bar" },
710+
new NestedItem { Name = "bar1" },
711711
new NestedItem { Name = "baz" },
712712
new NestedItem { Name = "new-bar" }
713713
]
@@ -717,6 +717,13 @@ public void DetectChanges_detects_changes_in_nested_complex_collections()
717717
changeDetector.DetectChanges(stateManager);
718718

719719
Assert.Equal(EntityState.Modified, entityEntry.EntityState);
720+
721+
var nestedJson = new EntityEntry<BlogWithNested>(entityEntry).ComplexProperty(b => b.NestedJson);
722+
var items = nestedJson.ComplexCollection(j => j.Items);
723+
Assert.Equal(3, items.CurrentValue!.Count);
724+
Assert.Equal(EntityState.Modified, items[0].State);
725+
Assert.Equal(EntityState.Unchanged, items[1].State);
726+
Assert.Equal(EntityState.Added, items[2].State);
720727
}
721728

722729
private static IModel CreateModel()

0 commit comments

Comments
 (0)