Skip to content

Commit

Permalink
Merge in 'release/8.0' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot committed Oct 26, 2023
2 parents 1425f65 + 94bff5a commit 72b8d33
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 1 deletion.
93 changes: 93 additions & 0 deletions src/EFCore/Metadata/IEntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,99 @@ public interface IEntityType : IReadOnlyEntityType, ITypeBase
/// <returns>The indexes defined on this entity type.</returns>
new IEnumerable<IIndex> GetIndexes();

// The following methods are needed for binary compatibility
#region DO NOT DELETE

/// <summary>
/// Gets a property on the given entity type. Returns <see langword="null" /> if no property is found.
/// </summary>
/// <remarks>
/// This API only finds scalar properties and does not find navigation properties. Use
/// <see cref="FindNavigation(MemberInfo)" /> to find a navigation property.
/// </remarks>
/// <param name="memberInfo">The property on the entity class.</param>
/// <returns>The property, or <see langword="null" /> if none is found.</returns>
new IProperty? FindProperty(MemberInfo memberInfo)
=> (IProperty?)((IReadOnlyEntityType)this).FindProperty(memberInfo);

/// <summary>
/// Gets the property with a given name. Returns <see langword="null" /> if no property with the given name is defined.
/// </summary>
/// <remarks>
/// This API only finds scalar properties and does not find navigation properties. Use
/// <see cref="FindNavigation(string)" /> to find a navigation property.
/// </remarks>
/// <param name="name">The name of the property.</param>
/// <returns>The property, or <see langword="null" /> if none is found.</returns>
new IProperty? FindProperty(string name);

/// <summary>
/// Finds matching properties on the given entity type. Returns <see langword="null" /> if any property is not found.
/// </summary>
/// <remarks>
/// This API only finds scalar properties and does not find navigation properties.
/// </remarks>
/// <param name="propertyNames">The property names.</param>
/// <returns>The properties, or <see langword="null" /> if any property is not found.</returns>
new IReadOnlyList<IProperty>? FindProperties(
IReadOnlyList<string> propertyNames)
=> (IReadOnlyList<IProperty>?)((IReadOnlyEntityType)this).FindProperties(propertyNames);

/// <summary>
/// Gets a property with the given name.
/// </summary>
/// <remarks>
/// This API only finds scalar properties and does not find navigation properties. Use
/// <see cref="FindNavigation(string)" /> to find a navigation property.
/// </remarks>
/// <param name="name">The property name.</param>
/// <returns>The property.</returns>
new IProperty GetProperty(string name)
=> (IProperty)((IReadOnlyEntityType)this).GetProperty(name);

/// <summary>
/// Finds a property declared on the type with the given name.
/// Does not return properties defined on a base type.
/// </summary>
/// <param name="name">The property name.</param>
/// <returns>The property, or <see langword="null" /> if none is found.</returns>
new IProperty? FindDeclaredProperty(string name);

/// <summary>
/// Gets all non-navigation properties declared on the given <see cref="IEntityType" />.
/// </summary>
/// <remarks>
/// This method does not return properties declared on base types.
/// It is useful when iterating over all entity types to avoid processing the same property more than once.
/// Use <see cref="GetProperties" /> to also return properties declared on base types.
/// </remarks>
/// <returns>Declared non-navigation properties.</returns>
new IEnumerable<IProperty> GetDeclaredProperties();

/// <summary>
/// Gets all non-navigation properties declared on the types derived from this entity type.
/// </summary>
/// <remarks>
/// This method does not return properties declared on the given entity type itself.
/// Use <see cref="GetProperties" /> to return properties declared on this
/// and base entity typed types.
/// </remarks>
/// <returns>Derived non-navigation properties.</returns>
new IEnumerable<IProperty> GetDerivedProperties()
=> ((IReadOnlyEntityType)this).GetDerivedProperties().Cast<IProperty>();

/// <summary>
/// Gets the properties defined on this entity type.
/// </summary>
/// <remarks>
/// This API only returns scalar properties and does not return navigation properties. Use
/// <see cref="GetNavigations()" /> to get navigation properties.
/// </remarks>
/// <returns>The properties defined on this entity type.</returns>
new IEnumerable<IProperty> GetProperties();

#endregion

/// <summary>
/// Returns the properties contained in foreign keys.
/// </summary>
Expand Down
36 changes: 36 additions & 0 deletions src/EFCore/Metadata/Internal/EntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4104,6 +4104,42 @@ IEnumerable<ISkipNavigation> IEntityType.GetSkipNavigations()
IConventionSkipNavigation? IConventionEntityType.RemoveSkipNavigation(IReadOnlySkipNavigation navigation)
=> RemoveSkipNavigation((SkipNavigation)navigation);

/// <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
/// 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]
IProperty? IEntityType.FindProperty(string name) => FindProperty(name);

/// <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
/// 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]
IProperty? IEntityType.FindDeclaredProperty(string name) => FindDeclaredProperty(name);

/// <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
/// 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]
IEnumerable<IProperty> IEntityType.GetDeclaredProperties() => GetDeclaredProperties();

/// <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
/// 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]
IEnumerable<IProperty> IEntityType.GetProperties() => GetProperties();

/// <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
21 changes: 21 additions & 0 deletions src/EFCore/Metadata/RuntimeEntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,27 @@ IEnumerable<ITrigger> IEntityType.GetDeclaredTriggers()
? new RelationshipSnapshotFactoryFactory().Create(entityType)
: throw new InvalidOperationException(CoreStrings.NativeAotNoCompiledModel));

/// <inheritdoc />
[DebuggerStepThrough]
IProperty? IEntityType.FindProperty(string name) => FindProperty(name);

/// <inheritdoc />
[DebuggerStepThrough]
IReadOnlyList<IProperty>? IEntityType.FindProperties(IReadOnlyList<string> propertyNames)
=> FindProperties(propertyNames);

/// <inheritdoc />
[DebuggerStepThrough]
IProperty? IEntityType.FindDeclaredProperty(string name) => FindDeclaredProperty(name);

/// <inheritdoc />
[DebuggerStepThrough]
IEnumerable<IProperty> IEntityType.GetDeclaredProperties() => GetDeclaredProperties();

/// <inheritdoc />
[DebuggerStepThrough]
IEnumerable<IProperty> IEntityType.GetProperties() => GetProperties();

/// <inheritdoc />
[DebuggerStepThrough]
IEnumerable<IProperty> IEntityType.GetForeignKeyProperties()
Expand Down
9 changes: 8 additions & 1 deletion src/EFCore/Metadata/RuntimeTypeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,14 @@ protected virtual IEnumerable<T> GetDerivedTypes<T>()
public virtual RuntimeProperty? FindProperty(string name)
=> FindDeclaredProperty(name) ?? _baseType?.FindProperty(name);

private RuntimeProperty? FindDeclaredProperty(string name)
/// <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
/// 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>
[EntityFrameworkInternal]
protected virtual RuntimeProperty? FindDeclaredProperty(string name)
=> _properties.TryGetValue(name, out var property)
? property
: null;
Expand Down

0 comments on commit 72b8d33

Please sign in to comment.