コード例 #1
0
ファイル: KeyExtensions.cs プロジェクト: yangmaomao86/efcore
        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());
        }
コード例 #2
0
ファイル: KeyExtensions.cs プロジェクト: ebekker/efcore
        /// <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);
        }
コード例 #3
0
 /// <inheritdoc />
 protected override bool AreCompatible(IReadOnlyKey key, IReadOnlyKey duplicateKey, in StoreObjectIdentifier storeObject)
コード例 #4
0
ファイル: CosmosTestStore.cs プロジェクト: AshkanAbd/efcore
 IReadOnlyForeignKey IReadOnlyEntityType.FindForeignKey(
     IReadOnlyList <IReadOnlyProperty> properties, IReadOnlyKey principalKey, IReadOnlyEntityType principalEntityType)
 => throw new NotImplementedException();
コード例 #5
0
 public static IMutableForeignKey?FindForeignKey(
     [NotNull] this IMutableEntityType entityType,
     [NotNull] IReadOnlyProperty property,
     [NotNull] IReadOnlyKey principalKey,
     [NotNull] IReadOnlyEntityType principalEntityType)
 => entityType.FindForeignKey(new[] { property }, principalKey, principalEntityType);
コード例 #6
0
 /// <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)
コード例 #7
0
ファイル: KeyExtensions.cs プロジェクト: yangmaomao86/efcore
 public static Key AsKey([NotNull] this IReadOnlyKey key, [NotNull][CallerMemberName] string methodName = "")
 => MetadataExtensions.AsConcreteMetadataType <IReadOnlyKey, Key>(key, methodName);
コード例 #8
0
 public static string?GetName([NotNull] this IReadOnlyKey key)
 => key.GetName(StoreObjectIdentifier.Table(key.DeclaringEntityType.GetTableName() !, key.DeclaringEntityType.GetSchema()));
コード例 #9
0
ファイル: KeyExtensions.cs プロジェクト: yangmaomao86/efcore
 public static IEnumerable <IReadOnlyForeignKey> GetReferencingForeignKeys([NotNull] this IReadOnlyKey key)
 => Check.NotNull(key, nameof(key)).AsKey().ReferencingForeignKeys ?? Enumerable.Empty <IReadOnlyForeignKey>();
コード例 #10
0
ファイル: KeyExtensions.cs プロジェクト: yangmaomao86/efcore
 public static Type GetKeyType([NotNull] this IReadOnlyKey key)
 => key.Properties.Count > 1 ? typeof(object[]) : key.Properties.First().ClrType;
コード例 #11
0
ファイル: KeyExtensions.cs プロジェクト: yangmaomao86/efcore
 public static IPrincipalKeyValueFactory <TKey> GetPrincipalKeyValueFactory <TKey>([NotNull] this IReadOnlyKey key)
 => key.AsKey().GetPrincipalKeyValueFactory <TKey>();
コード例 #12
0
 /// <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)
コード例 #13
0
 public static bool AreCompatibleForSqlServer(
     [NotNull] this IReadOnlyKey key,
     [NotNull] IReadOnlyKey duplicateKey,
     in StoreObjectIdentifier storeObject,
コード例 #14
0
 /// <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)
コード例 #15
0
    /// <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));
    }
コード例 #16
0
 /// <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];
コード例 #17
0
 /// <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)
コード例 #18
0
ファイル: KeyExtensions.cs プロジェクト: yangmaomao86/efcore
 public static bool IsPrimaryKey([NotNull] this IReadOnlyKey key)
 => key == key.DeclaringEntityType.FindPrimaryKey();
コード例 #19
0
 /// <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,
コード例 #20
0
ファイル: KeyExtensions.cs プロジェクト: yangmaomao86/efcore
 public static Func <bool, IIdentityMap> GetIdentityMapFactory([NotNull] this IReadOnlyKey key)
 => key.AsKey().IdentityMapFactory;