Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions EFCore.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/FORCE_ATTRIBUTE_STYLE/@EntryValue">Join</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/OBJECT_CREATION_WHEN_TYPE_NOT_EVIDENT/@EntryValue">ExplicitlyTyped</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARGUMENT/@EntryValue">False</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
<Using Include="Microsoft.EntityFrameworkCore.Storage" />
<Using Include="Microsoft.EntityFrameworkCore.Storage.ValueConversion" />
<Using Include="Microsoft.EntityFrameworkCore.Update" />
<Using Include="Microsoft.EntityFrameworkCore.ValueGeneration" />
<Using Include="Microsoft.EntityFrameworkCore.Utilities" />
<Using Include="Microsoft.EntityFrameworkCore.ValueGeneration" />
<Using Include="Microsoft.EntityFrameworkCore.Query" />
<Using Include="Microsoft.Extensions.Logging" />
<Using Include="Microsoft.Extensions.DependencyInjection" />
</ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions src/EFCore/ChangeTracking/CollectionEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking;
/// </remarks>
public class CollectionEntry : NavigationEntry
{
private ICollectionLoader? _loader;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -164,11 +162,12 @@ public override bool IsModified
{
var joinEntityType = skipNavigation.JoinEntityType;
var foreignKey = skipNavigation.ForeignKey;
foreach (var joinEntry in stateManager
.GetEntriesForState(added: !value, modified: !value, deleted: !value, unchanged: value).Where(
e => e.EntityType == joinEntityType
&& stateManager.FindPrincipal(e, foreignKey) == InternalEntry)
.ToList())
var joinEntries = stateManager
.GetEntriesForState(added: !value, modified: !value, deleted: !value, unchanged: value)
.Where(e => e.EntityType == joinEntityType
&& stateManager.FindPrincipal(e, foreignKey) == InternalEntry)
.ToList();
foreach (var joinEntry in joinEntries)
{
joinEntry.SetEntityState(value ? EntityState.Modified : EntityState.Unchanged);
}
Expand Down Expand Up @@ -335,8 +334,9 @@ private void EnsureInitialized()
? null
: InternalEntry.StateManager.GetOrCreateEntry(entity, Metadata.TargetEntityType);

[field: AllowNull, MaybeNull]
private ICollectionLoader TargetLoader
=> _loader ??= Metadata is IRuntimeSkipNavigation skipNavigation
=> field ??= Metadata is IRuntimeSkipNavigation skipNavigation
? skipNavigation.GetManyToManyLoader()
: new EntityFinderCollectionLoaderAdapter(
InternalEntry.StateManager.CreateEntityFinder(Metadata.TargetEntityType),
Expand Down
8 changes: 4 additions & 4 deletions src/EFCore/ChangeTracking/ComplexCollectionEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,18 @@ private void DetectChanges()
}

/// <summary>
/// Gets a <see cref="ComplexElementEntry"/> for the complex item at the specified ordinal.
/// Gets a <see cref="ComplexElementEntry" /> for the complex item at the specified ordinal.
/// </summary>
/// <param name="ordinal">The ordinal of the complex item to access.</param>
/// <returns>A <see cref="ComplexElementEntry"/> for the complex item at the specified ordinal.</returns>
/// <returns>A <see cref="ComplexElementEntry" /> for the complex item at the specified ordinal.</returns>
public virtual ComplexElementEntry this[int ordinal]
=> new(InternalEntry.GetComplexCollectionEntry(Metadata, ordinal));

/// <summary>
/// Gets a <see cref="ComplexElementEntry"/> for the original complex item at the specified ordinal.
/// Gets a <see cref="ComplexElementEntry" /> for the original complex item at the specified ordinal.
/// </summary>
/// <param name="ordinal">The original ordinal of the complex item to access.</param>
/// <returns>A <see cref="ComplexElementEntry"/> for the complex item at the specified original ordinal.</returns>
/// <returns>A <see cref="ComplexElementEntry" /> for the complex item at the specified original ordinal.</returns>
public virtual ComplexElementEntry GetOriginalEntry(int ordinal)
=> new(InternalEntry.GetComplexCollectionOriginalEntry(Metadata, ordinal));

Expand Down
8 changes: 4 additions & 4 deletions src/EFCore/ChangeTracking/ComplexCollectionEntry`.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ public override EntityEntry<TEntity> EntityEntry
}

/// <summary>
/// Gets a <see cref="ComplexElementEntry{TEntity, TElement}"/> for the complex item at the specified ordinal.
/// Gets a <see cref="ComplexElementEntry{TEntity, TElement}" /> for the complex item at the specified ordinal.
/// </summary>
/// <param name="ordinal">The ordinal of the complex item to access.</param>
/// <returns>A <see cref="ComplexElementEntry{TEntity, TElement}"/> for the complex item at the specified ordinal.</returns>
/// <returns>A <see cref="ComplexElementEntry{TEntity, TElement}" /> for the complex item at the specified ordinal.</returns>
public override ComplexElementEntry<TEntity, TElement> this[int ordinal]
=> new(InternalEntry.GetComplexCollectionEntry(Metadata, ordinal));

/// <summary>
/// Gets a <see cref="ComplexElementEntry{TEntity, TElement}"/> for the complex item at the specified original ordinal.
/// Gets a <see cref="ComplexElementEntry{TEntity, TElement}" /> for the complex item at the specified original ordinal.
/// </summary>
/// <param name="ordinal">The original ordinal of the complex item to access.</param>
/// <returns>A <see cref="ComplexElementEntry{TEntity, TElement}"/> for the original complex item at the specified ordinal.</returns>
/// <returns>A <see cref="ComplexElementEntry{TEntity, TElement}" /> for the original complex item at the specified ordinal.</returns>
public override ComplexElementEntry<TEntity, TElement> GetOriginalEntry(int ordinal)
=> new(InternalEntry.GetComplexCollectionOriginalEntry(Metadata, ordinal));
}
10 changes: 5 additions & 5 deletions src/EFCore/ChangeTracking/ComplexElementEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public class ComplexElementEntry : IInfrastructure<InternalComplexEntry>
/// </summary>
[EntityFrameworkInternal]
public ComplexElementEntry(InternalComplexEntry internalEntry)
{
InternalEntry = internalEntry;
}
=> InternalEntry = internalEntry;

/// <summary>
/// Gets or sets a value indicating whether any of the properties of the complex type have been modified
Expand Down Expand Up @@ -85,7 +83,8 @@ public virtual bool IsModified
/// <summary>
/// Gets the metadata that describes the facets of this property and how it maps to the database.
/// </summary>
public virtual IComplexProperty Metadata => InternalEntry.ComplexProperty;
public virtual IComplexProperty Metadata
=> InternalEntry.ComplexProperty;

/// <summary>
/// Gets or sets the value currently assigned to this property. If the current value is set using this property,
Expand Down Expand Up @@ -273,7 +272,8 @@ public virtual ComplexCollectionEntry ComplexCollection(string propertyName)
/// examples.
/// </remarks>
public virtual IEnumerable<ComplexCollectionEntry> ComplexCollections
=> Metadata.ComplexType.GetComplexProperties().Where(p => p.IsCollection).Select(property => new ComplexCollectionEntry(InternalEntry, property));
=> Metadata.ComplexType.GetComplexProperties().Where(p => p.IsCollection)
.Select(property => new ComplexCollectionEntry(InternalEntry, property));

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
6 changes: 4 additions & 2 deletions src/EFCore/ChangeTracking/ComplexPropertyEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ public virtual ComplexPropertyEntry ComplexProperty(string propertyName)
/// examples.
/// </remarks>
public virtual IEnumerable<ComplexPropertyEntry> ComplexProperties
=> Metadata.ComplexType.GetComplexProperties().Where(p => !p.IsCollection).Select(property => new ComplexPropertyEntry(InternalEntry, property));
=> Metadata.ComplexType.GetComplexProperties().Where(p => !p.IsCollection)
.Select(property => new ComplexPropertyEntry(InternalEntry, property));

/// <summary>
/// Provides access to change tracking information and operations for a given collection property of a complex type on this complex type.
Expand Down Expand Up @@ -208,5 +209,6 @@ public virtual ComplexCollectionEntry ComplexCollection(string propertyName)
/// examples.
/// </remarks>
public virtual IEnumerable<ComplexCollectionEntry> ComplexCollections
=> Metadata.ComplexType.GetComplexProperties().Where(p => p.IsCollection).Select(property => new ComplexCollectionEntry(InternalEntry, property));
=> Metadata.ComplexType.GetComplexProperties().Where(p => p.IsCollection)
.Select(property => new ComplexCollectionEntry(InternalEntry, property));
}
4 changes: 2 additions & 2 deletions src/EFCore/ChangeTracking/DetectEntityChangesEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking;
public class DetectEntityChangesEventArgs : DetectChangesEventArgs
{
private readonly InternalEntityEntry _internalEntityEntry;
private EntityEntry? _entry;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -29,6 +28,7 @@ public DetectEntityChangesEventArgs(InternalEntityEntry internalEntityEntry)
/// <summary>
/// The <see cref="EntityEntry" /> for the entity.
/// </summary>
[field: AllowNull, MaybeNull]
public virtual EntityEntry Entry
=> _entry ??= new EntityEntry(_internalEntityEntry);
=> field ??= new EntityEntry(_internalEntityEntry);
}
4 changes: 2 additions & 2 deletions src/EFCore/ChangeTracking/DetectedEntityChangesEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking;
public class DetectedEntityChangesEventArgs : DetectedChangesEventArgs
{
private readonly InternalEntityEntry _internalEntityEntry;
private EntityEntry? _entry;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -32,6 +31,7 @@ public DetectedEntityChangesEventArgs(
/// <summary>
/// The <see cref="EntityEntry" /> for the entity.
/// </summary>
[field: AllowNull, MaybeNull]
public virtual EntityEntry Entry
=> _entry ??= new EntityEntry(_internalEntityEntry);
=> field ??= new EntityEntry(_internalEntityEntry);
}
17 changes: 9 additions & 8 deletions src/EFCore/ChangeTracking/EntityEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking;
public class EntityEntry : IInfrastructure<InternalEntityEntry>
{
private static readonly int MaxEntityState = Enum.GetValuesAsUnderlyingType<EntityState>().Cast<int>().Max();
private IEntityFinder? _finder;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -277,10 +276,9 @@ public virtual IEnumerable<NavigationEntry> Navigations
var entityType = InternalEntry.EntityType;
return entityType.GetNavigations()
.Concat<INavigationBase>(entityType.GetSkipNavigations())
.Select(
navigation => navigation.IsCollection
? (NavigationEntry)new CollectionEntry(InternalEntry, navigation)
: new ReferenceEntry(InternalEntry, navigation));
.Select(navigation => navigation.IsCollection
? (NavigationEntry)new CollectionEntry(InternalEntry, navigation)
: new ReferenceEntry(InternalEntry, navigation));
}
}

Expand Down Expand Up @@ -367,7 +365,8 @@ public virtual ComplexPropertyEntry ComplexProperty(string propertyName)
/// examples.
/// </remarks>
public virtual IEnumerable<ComplexPropertyEntry> ComplexProperties
=> Metadata.GetComplexProperties().Where(p => !p.IsCollection).Select(property => new ComplexPropertyEntry(InternalEntry, property));
=> Metadata.GetComplexProperties().Where(p => !p.IsCollection)
.Select(property => new ComplexPropertyEntry(InternalEntry, property));

/// <summary>
/// Provides access to change tracking information and operations for a given collection property of a complex type on this entity.
Expand Down Expand Up @@ -409,7 +408,8 @@ public virtual ComplexCollectionEntry ComplexCollection(string propertyName)
/// examples.
/// </remarks>
public virtual IEnumerable<ComplexCollectionEntry> ComplexCollections
=> Metadata.GetComplexProperties().Where(p => p.IsCollection).Select(property => new ComplexCollectionEntry(InternalEntry, property));
=> Metadata.GetComplexProperties().Where(p => p.IsCollection)
.Select(property => new ComplexCollectionEntry(InternalEntry, property));

/// <summary>
/// Provides access to change tracking and loading information for a reference (i.e. non-collection)
Expand Down Expand Up @@ -696,8 +696,9 @@ private void Reload(PropertyValues? storeValues)
}
}

[field: AllowNull, MaybeNull]
private IEntityFinder Finder
=> _finder ??= InternalEntry.StateManager.CreateEntityFinder(InternalEntry.EntityType);
=> field ??= InternalEntry.StateManager.CreateEntityFinder(InternalEntry.EntityType);

/// <summary>
/// Returns a string that represents the current object.
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore/ChangeTracking/EntityEntryEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking;
public class EntityEntryEventArgs : EventArgs
{
private readonly InternalEntityEntry _internalEntityEntry;
private EntityEntry? _entry;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -31,6 +30,7 @@ public EntityEntryEventArgs(
/// <summary>
/// The <see cref="EntityEntry" /> for the entity.
/// </summary>
[field: AllowNull, MaybeNull]
public virtual EntityEntry Entry
=> _entry ??= new EntityEntry(_internalEntityEntry);
=> field ??= new EntityEntry(_internalEntityEntry);
}
3 changes: 1 addition & 2 deletions src/EFCore/ChangeTracking/EntityEntryGraphNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public class EntityEntryGraphNode : IInfrastructure<InternalEntityEntry>
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[DebuggerStepThrough]
[EntityFrameworkInternal]
[DebuggerStepThrough, EntityFrameworkInternal]
public EntityEntryGraphNode(
InternalEntityEntry entry,
InternalEntityEntry? sourceEntry,
Expand Down
3 changes: 1 addition & 2 deletions src/EFCore/ChangeTracking/EntityEntryGraphNode`.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public class EntityEntryGraphNode<TState> : EntityEntryGraphNode
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[DebuggerStepThrough]
[EntityFrameworkInternal]
[DebuggerStepThrough, EntityFrameworkInternal]
public EntityEntryGraphNode(
InternalEntityEntry entry,
TState state,
Expand Down
6 changes: 2 additions & 4 deletions src/EFCore/ChangeTracking/GeometryValueComparer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;

namespace Microsoft.EntityFrameworkCore.ChangeTracking;

/// <summary>
Expand All @@ -12,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking;
/// See <see href="https://aka.ms/efcore-docs-value-comparers">EF Core value comparers</see> for more information and examples.
/// </remarks>
public class GeometryValueComparer
<[DynamicallyAccessedMembers(
<[DynamicallyAccessedMembers(
DynamicallyAccessedMemberTypes.PublicMethods
| DynamicallyAccessedMemberTypes.PublicProperties)]
TGeometry>
Expand Down Expand Up @@ -43,7 +41,7 @@ public GeometryValueComparer()
return Expression.Lambda<Func<TGeometry?, TGeometry?, bool>>(
Expression.Block(
typeof(bool),
new[] { x, y, xNull, yNull },
[x, y, xNull, yNull],
Expression.Assign(x, left),
Expression.Assign(y, right),
Expression.Assign(xNull, Expression.ReferenceEqual(x, nullExpression)),
Expand Down
1 change: 0 additions & 1 deletion src/EFCore/ChangeTracking/IDependentKeyValueFactory`.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using JetBrains.Annotations;

namespace Microsoft.EntityFrameworkCore.ChangeTracking;
Expand Down
Loading
Loading