Exemplo n.º 1
0
 /// <summary>
 ///     Constructs the event payload.
 /// </summary>
 /// <param name="eventDefinition">The event definition.</param>
 /// <param name="messageGenerator">A delegate that generates a log message for this event.</param>
 /// <param name="navigation">The navigation.</param>
 public NavigationEventData(
     EventDefinitionBase eventDefinition,
     Func <EventDefinitionBase, EventData, string> messageGenerator,
     IReadOnlyNavigation navigation)
     : base(eventDefinition, messageGenerator)
 {
     Navigation = navigation;
 }
Exemplo n.º 2
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 IsEmbedded(this IReadOnlyNavigation navigation)
 => !navigation.IsOnDependent &&
 !navigation.ForeignKey.DeclaringEntityType.IsDocumentRoot();
Exemplo n.º 3
0
 public static IReadOnlyEntityType GetTargetType([NotNull] this IReadOnlyNavigation navigation)
     => Check.NotNull(navigation, nameof(navigation)).TargetEntityType;
Exemplo n.º 4
0
 public static bool IsEagerLoaded([NotNull] this IReadOnlyNavigation navigation)
     => Check.NotNull(navigation, nameof(navigation)).IsEagerLoaded;
Exemplo n.º 5
0
 public static IReadOnlyNavigation? FindInverse([NotNull] this IReadOnlyNavigation navigation)
     => Check.NotNull(navigation, nameof(navigation)).Inverse;
Exemplo n.º 6
0
 public static bool IsCollection([NotNull] this IReadOnlyNavigation navigation)
     => Check.NotNull(navigation, nameof(navigation)).IsCollection;
Exemplo n.º 7
0
 public static bool IsDependentToPrincipal([NotNull] this IReadOnlyNavigation navigation)
     => Check.NotNull(navigation, nameof(navigation)).IsOnDependent;
Exemplo n.º 8
0
 public static Navigation AsNavigation([NotNull] this IReadOnlyNavigation navigation, [NotNull][CallerMemberName] string methodName = "")
 => MetadataExtensions.AsConcreteMetadataType <IReadOnlyNavigation, Navigation>(navigation, methodName);
Exemplo n.º 9
0
        public static string ToDebugString(
            [NotNull] this IReadOnlyNavigation navigation,
            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($"Navigation: {navigation.DeclaringEntityType.DisplayName()}.");
            }

            builder.Append(navigation.Name);

            var field = navigation.GetFieldName();

            if (field == null)
            {
                builder.Append(" (no field, ");
            }
            else if (!field.EndsWith(">k__BackingField", StringComparison.Ordinal))
            {
                builder.Append($" ({field}, ");
            }
            else
            {
                builder.Append(" (");
            }

            builder.Append(navigation.ClrType?.ShortDisplayName()).Append(")");

            if (navigation.IsCollection)
            {
                builder.Append(" Collection");
            }

            builder.Append(navigation.IsOnDependent ? " ToPrincipal " : " ToDependent ");

            builder.Append(navigation.TargetEntityType.DisplayName());

            if (navigation.Inverse != null)
            {
                builder.Append(" Inverse: ").Append(navigation.Inverse.Name);
            }

            if (navigation.GetPropertyAccessMode() != PropertyAccessMode.PreferField)
            {
                builder.Append(" PropertyAccessMode.").Append(navigation.GetPropertyAccessMode());
            }

            if ((options & MetadataDebugStringOptions.IncludePropertyIndexes) != 0 &&
                ((Annotatable)navigation).IsReadOnly)
            {
                var indexes = ((INavigation)navigation).GetPropertyIndexes();
                builder.Append(" ").Append(indexes.Index);
                builder.Append(" ").Append(indexes.OriginalValueIndex);
                builder.Append(" ").Append(indexes.RelationshipIndex);
                builder.Append(" ").Append(indexes.ShadowIndex);
                builder.Append(" ").Append(indexes.StoreGenerationIndex);
            }

            if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
            {
                builder.Append(navigation.AnnotationsToDebugString(indent + 2));
            }

            return(builder.ToString());
        }