Ejemplo n.º 1
0
 public static bool CanSetHasOperators(
     [NotNull] this IConventionIndexBuilder indexBuilder, [CanBeNull] IReadOnlyList <string> operators,
     bool fromDataAnnotation)
 => CanSetOperators(indexBuilder, operators, fromDataAnnotation);
 public OnIndexUniquenessChangedNode(IConventionIndexBuilder indexBuilder)
 {
     IndexBuilder = indexBuilder;
 }
Ejemplo n.º 3
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 virtual IConventionIndexBuilder OnIndexAdded([NotNull] IConventionIndexBuilder indexBuilder)
 => _scope.OnIndexAdded(indexBuilder);
Ejemplo n.º 4
0
 public static bool CanSetFilter(
     [NotNull] this IConventionIndexBuilder indexBuilder,
     [CanBeNull] string?sql,
     bool fromDataAnnotation = false)
 => indexBuilder.CanSetAnnotation(RelationalAnnotationNames.Filter, sql, fromDataAnnotation);
 public override bool?OnIndexUniquenessChanged(IConventionIndexBuilder indexBuilder)
 {
     Add(new OnIndexUniquenessChangedNode(indexBuilder));
     return(indexBuilder.Metadata.IsUnique);
 }
Ejemplo n.º 6
0
 public static bool CanSetInclude(
     this IConventionIndexBuilder indexBuilder,
     IReadOnlyList <string>?propertyNames,
     bool fromDataAnnotation = false)
 => CanSetIncludeProperties(indexBuilder, propertyNames, fromDataAnnotation);
Ejemplo n.º 7
0
 public static bool CanSetDatabaseName(
     [NotNull] this IConventionIndexBuilder indexBuilder,
     [CanBeNull] string?name,
     bool fromDataAnnotation = false)
 => indexBuilder.CanSetAnnotation(RelationalAnnotationNames.Name, name, fromDataAnnotation);
 public abstract IConventionAnnotation?OnIndexAnnotationChanged(
     IConventionIndexBuilder indexBuilder,
     string name,
     IConventionAnnotation?annotation,
     IConventionAnnotation?oldAnnotation);
 public abstract IConventionIndexBuilder?OnIndexAdded([NotNull] IConventionIndexBuilder indexBuilder);
Ejemplo n.º 10
0
 public abstract IReadOnlyList <bool>?OnIndexSortOrderChanged(IConventionIndexBuilder indexBuilder);
 public abstract IConventionIndexBuilder?OnIndexAdded(IConventionIndexBuilder indexBuilder);
Ejemplo n.º 12
0
        private void CheckIndexAttributesAndEnsureIndex(
            IConventionEntityType entityType,
            bool shouldThrow)
        {
            if (entityType.ClrType == null)
            {
                return;
            }

            foreach (var indexAttribute in
                     entityType.ClrType.GetCustomAttributes <IndexAttribute>(true))
            {
                IConventionIndexBuilder indexBuilder = null;
                if (!shouldThrow)
                {
                    var indexProperties = new List <IConventionProperty>();
                    foreach (var propertyName in indexAttribute.PropertyNames)
                    {
                        var property = entityType.FindProperty(propertyName);
                        if (property == null)
                        {
                            return;
                        }

                        indexProperties.Add(property);
                    }

                    indexBuilder = indexAttribute.Name == null
                        ? entityType.Builder.HasIndex(
                        indexProperties, fromDataAnnotation : true)
                        : entityType.Builder.HasIndex(
                        indexProperties, indexAttribute.Name, fromDataAnnotation: true);
                }
                else
                {
                    try
                    {
                        // Using the HasIndex(propertyNames) overload gives us
                        // a chance to create a missing property
                        // e.g. if the CLR property existed but was non-public.
                        indexBuilder = indexAttribute.Name == null
                            ? entityType.Builder.HasIndex(
                            indexAttribute.PropertyNames, fromDataAnnotation : true)
                            : entityType.Builder.HasIndex(
                            indexAttribute.PropertyNames, indexAttribute.Name, fromDataAnnotation: true);
                    }
                    catch (InvalidOperationException exception)
                    {
                        CheckMissingProperties(indexAttribute, entityType, exception);

                        throw;
                    }
                }

                if (indexBuilder == null)
                {
                    CheckIgnoredProperties(indexAttribute, entityType);
                }
                else
                {
                    var shouldBeUnique = indexAttribute.GetIsUnique();
                    if (shouldBeUnique.HasValue)
                    {
                        indexBuilder.IsUnique(shouldBeUnique.Value, fromDataAnnotation: true);
                    }
                }
            }
        }
Ejemplo n.º 13
0
 public override IConventionIndexBuilder OnIndexUniquenessChanged(IConventionIndexBuilder indexBuilder)
 {
     Add(new OnIndexUniquenessChangedNode(indexBuilder));
     return(indexBuilder);
 }
Ejemplo n.º 14
0
 public static bool CanSetHasSortOrder(
     [NotNull] this IConventionIndexBuilder indexBuilder,
     [CanBeNull] IReadOnlyList <SortOrder> values,
     bool fromDataAnnotation)
 => CanSetSortOrder(indexBuilder, values, fromDataAnnotation);
Ejemplo n.º 15
0
 public static bool CanSetToTsVector(
     this IConventionIndexBuilder indexBuilder,
     string?config,
     bool fromDataAnnotation = false)
 => CanSetIsTsVectorExpressionIndex(indexBuilder, config, fromDataAnnotation);
 public abstract IConventionAnnotation?OnIndexAnnotationChanged(
     [NotNull] IConventionIndexBuilder indexBuilder,
     [NotNull] string name,
     [CanBeNull] IConventionAnnotation?annotation,
     [CanBeNull] IConventionAnnotation?oldAnnotation);
Ejemplo n.º 17
0
 public static bool CanSetHasNullSortOrder(
     this IConventionIndexBuilder indexBuilder,
     IReadOnlyList <NullSortOrder>?values,
     bool fromDataAnnotation)
 => CanSetNullSortOrder(indexBuilder, values, fromDataAnnotation);
 public abstract bool?OnIndexUniquenessChanged([NotNull] IConventionIndexBuilder indexBuilder);
Ejemplo n.º 19
0
 public static IConventionIndexBuilder?HasName(
     [NotNull] this IConventionIndexBuilder indexBuilder,
     [CanBeNull] string?name,
     bool fromDataAnnotation = false)
 => indexBuilder.HasDatabaseName(name, fromDataAnnotation);
Ejemplo n.º 20
0
 /// <summary>
 ///     Called after the uniqueness for an index is changed.
 /// </summary>
 /// <param name="indexBuilder">The builder for the index.</param>
 /// <param name="context">Additional information associated with convention execution.</param>
 public virtual void ProcessIndexUniquenessChanged(
     IConventionIndexBuilder indexBuilder,
     IConventionContext <bool?> context)
 => SetIndexFilter(indexBuilder);
Ejemplo n.º 21
0
 public static bool CanSetName(
     [NotNull] this IConventionIndexBuilder indexBuilder,
     [CanBeNull] string?name,
     bool fromDataAnnotation = false)
 => CanSetDatabaseName(indexBuilder, name, fromDataAnnotation);
Ejemplo n.º 22
0
 /// <summary>
 ///     Called after an index is added to the entity type.
 /// </summary>
 /// <param name="indexBuilder">The builder for the index.</param>
 /// <param name="context">Additional information associated with convention execution.</param>
 public virtual void ProcessIndexAdded(
     IConventionIndexBuilder indexBuilder,
     IConventionContext <IConventionIndexBuilder> context)
 => SetIndexFilter(indexBuilder);
 public override IConventionIndexBuilder OnIndexAdded(IConventionIndexBuilder indexBuilder)
 {
     Add(new OnIndexAddedNode(indexBuilder));
     return(indexBuilder);
 }
Ejemplo n.º 24
0
 public static bool CanSetHasCollation(
     this IConventionIndexBuilder indexBuilder,
     IReadOnlyList <string>?values,
     bool fromDataAnnotation)
 => CanSetCollation(indexBuilder, values, fromDataAnnotation);
 public OnIndexAddedNode(IConventionIndexBuilder indexBuilder)
 {
     IndexBuilder = indexBuilder;
 }
Ejemplo n.º 26
0
 public static bool CanSetHasMethod(
     this IConventionIndexBuilder indexBuilder, string?method, bool fromDataAnnotation = false)
 => CanSetMethod(indexBuilder, method, fromDataAnnotation);
 public void ProcessIndexAdded(
     IConventionIndexBuilder indexBuilder,
     IConventionContext <IConventionIndexBuilder> context)
 => indexBuilder.HasName(RewriteName(indexBuilder.Metadata.GetName()));
Ejemplo n.º 28
0
 public static bool CanSetHasOperators(
     this IConventionIndexBuilder indexBuilder, IReadOnlyList <string>?operators,
     bool fromDataAnnotation)
 => CanSetOperators(indexBuilder, operators, fromDataAnnotation);
Ejemplo n.º 29
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 virtual IConventionIndexBuilder OnIndexUniquenessChanged([NotNull] IConventionIndexBuilder indexBuilder)
 => _scope.OnIndexUniquenessChanged(indexBuilder);
Ejemplo n.º 30
0
 public static bool CanSetHasMethod(
     [NotNull] this IConventionIndexBuilder indexBuilder, [CanBeNull] string method,
     bool fromDataAnnotation = false)
 => CanSetMethod(indexBuilder, method, fromDataAnnotation);