public static string ToDebugString( [NotNull] this IReadOnlyKey key, MetadataDebugStringOptions options, int indent = 0) { var builder = new StringBuilder(); var indentString = new string(' ', indent); builder.Append(indentString); var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0; if (singleLine) { builder.Append("Key: "); } builder.AppendJoin( ", ", key.Properties.Select( p => singleLine ? p.DeclaringEntityType.DisplayName() + "." + p.Name : p.Name)); if (key.IsPrimaryKey()) { builder.Append(" PK"); } if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) { builder.Append(key.AnnotationsToDebugString(indent + 2)); } return(builder.ToString()); }
/// <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> public static int IndexOf(this IReadOnlyKey key, IReadOnlyProperty property) { var index = 0; for (; index < key.Properties.Count && key.Properties[index] != property; index++) { } return(index == key.Properties.Count ? -1 : index); }
/// <inheritdoc /> protected override bool AreCompatible(IReadOnlyKey key, IReadOnlyKey duplicateKey, in StoreObjectIdentifier storeObject)
IReadOnlyForeignKey IReadOnlyEntityType.FindForeignKey( IReadOnlyList <IReadOnlyProperty> properties, IReadOnlyKey principalKey, IReadOnlyEntityType principalEntityType) => throw new NotImplementedException();
public static IMutableForeignKey?FindForeignKey( [NotNull] this IMutableEntityType entityType, [NotNull] IReadOnlyProperty property, [NotNull] IReadOnlyKey principalKey, [NotNull] IReadOnlyEntityType principalEntityType) => entityType.FindForeignKey(new[] { property }, principalKey, principalEntityType);
/// <summary> /// Returns a value indicating whether the key is clustered. /// </summary> /// <param name="key"> The key. </param> /// <returns> <see langword="true" /> if the key is clustered. </returns> public static bool?IsClustered(this IReadOnlyKey key) => key is RuntimeKey ? throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData)
public static Key AsKey([NotNull] this IReadOnlyKey key, [NotNull][CallerMemberName] string methodName = "") => MetadataExtensions.AsConcreteMetadataType <IReadOnlyKey, Key>(key, methodName);
public static string?GetName([NotNull] this IReadOnlyKey key) => key.GetName(StoreObjectIdentifier.Table(key.DeclaringEntityType.GetTableName() !, key.DeclaringEntityType.GetSchema()));
public static IEnumerable <IReadOnlyForeignKey> GetReferencingForeignKeys([NotNull] this IReadOnlyKey key) => Check.NotNull(key, nameof(key)).AsKey().ReferencingForeignKeys ?? Enumerable.Empty <IReadOnlyForeignKey>();
public static Type GetKeyType([NotNull] this IReadOnlyKey key) => key.Properties.Count > 1 ? typeof(object[]) : key.Properties.First().ClrType;
public static IPrincipalKeyValueFactory <TKey> GetPrincipalKeyValueFactory <TKey>([NotNull] this IReadOnlyKey key) => key.AsKey().GetPrincipalKeyValueFactory <TKey>();
/// <summary> /// Returns a value indicating whether the key is clustered. /// </summary> /// <param name="key">The key.</param> /// <returns><see langword="true" /> if the key is clustered.</returns> public static bool?IsClustered(this IReadOnlyKey key) => (key is RuntimeKey)
public static bool AreCompatibleForSqlServer( [NotNull] this IReadOnlyKey key, [NotNull] IReadOnlyKey duplicateKey, in StoreObjectIdentifier storeObject,
/// <summary> /// Returns the key constraint name for this key for a particular table. /// </summary> /// <param name="key">The key.</param> /// <param name="storeObject">The identifier of the containing store object.</param> /// <returns>The key constraint name for this key.</returns> public static string?GetName(this IReadOnlyKey key, in StoreObjectIdentifier storeObject)
/// <summary> /// Returns the key constraint name for this key. /// </summary> /// <param name="key">The key.</param> /// <returns>The key constraint name for this key.</returns> public static string?GetName(this IReadOnlyKey key) { var table = StoreObjectIdentifier.Create(key.DeclaringEntityType, StoreObjectType.Table); return(!table.HasValue ? null : key.GetName(table.Value)); }
/// <summary> /// Returns a value indicating whether the key is clustered. /// </summary> /// <param name="key"> The key. </param> /// <returns> <see langword="true" /> if the key is clustered. </returns> public static bool?IsClustered(this IReadOnlyKey key) => (bool?)key[SqlServerAnnotationNames.Clustered];
/// <summary> /// Returns a value indicating whether the key is clustered. /// </summary> /// <param name="key"> The key. </param> /// <param name="storeObject"> The identifier of the store object. </param> /// <returns> <see langword="true" /> if the key is clustered. </returns> public static bool?IsClustered(this IReadOnlyKey key, in StoreObjectIdentifier storeObject)
public static bool IsPrimaryKey([NotNull] this IReadOnlyKey key) => key == key.DeclaringEntityType.FindPrimaryKey();
/// <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> public static bool AreCompatible( this IReadOnlyKey key, IReadOnlyKey duplicateKey, in StoreObjectIdentifier storeObject,
public static Func <bool, IIdentityMap> GetIdentityMapFactory([NotNull] this IReadOnlyKey key) => key.AsKey().IdentityMapFactory;