Ejemplo n.º 1
0
        private static void BuildIndex(
            AttributedIndexBuilderOptions options,
            EntityTypeBuilder builder1,
            OwnedNavigationBuilder builder2,
            IndexBuilderArgument builderArg,
            Action <IndexBuilder, IndexBuilderArgument> postProcess)
        {
            if (!options.SuppressNotSupportedException.IsClustered && builderArg.IsClustered)
            {
                throw new NotSupportedException(
                          "\"IsClustered=true\" of [Index] attribute is not supported.\n" +
                          "If you want to use \"IsClustered=true\", you need to call \"BuildIndexesFromAnnotationsForSqlServer()\" (in the Toolbelt.EntityFrameworkCore.IndexAttribute.SqlServer package) instead of \"BuildIndexesFromAnnotations()\", for a SQL Server connection.\n" +
                          "You can also suppress this exception by calling like \"BuildIndexesFromAnnotations(options => options.SupressUnsupportedException.IsClustered = true)\"");
            }

            if (!options.SuppressNotSupportedException.Includes && (builderArg.Includes ?? new string[0]).Any())
            {
                throw new NotSupportedException(
                          "\"Includes\" of [Index] attribute is not supported.\n" +
                          "If you want to use \"Includes\", you need to call \"BuildIndexesFromAnnotationsForSqlServer()\" (in the Toolbelt.EntityFrameworkCore.IndexAttribute.SqlServer package) instead of \"BuildIndexesFromAnnotations()\", for a SQL Server connection.\n" +
                          "You can also suppress this exception by calling like \"BuildIndexesFromAnnotations(options => options.SupressUnsupportedException.Includes = true)\"");
            }

            var indexBuilder = builder1?.HasIndex(builderArg.PropertyNames) ?? builder2.HasIndex(builderArg.PropertyNames);

            indexBuilder.IsUnique(builderArg.IsUnique);
            if (builderArg.IndexName != "")
            {
                indexBuilder.HasName(builderArg.IndexName);
            }
            postProcess?.Invoke(indexBuilder, builderArg);
        }
Ejemplo n.º 2
0
        public void ConfigureSearch <TOwner, TOwned>(OwnedNavigationBuilder <TOwner, TOwned> accessor)
            where TOwner : BaseEntity
            where TOwned : BaseEntity, IOwnedEntity, ISearchableEntity
        {
            PropertyBuilder <NpgsqlTsVector> property = accessor
                                                        .Property <NpgsqlTsVector>(nameof(ISearchableEntity.SearchVector))
                                                        .IsGeneratedTsVectorColumn("english", GetSearchProperties().GetPropertyAccessList().Select(ReflectionExtensions.GetSimpleMemberName).ToArray());

            accessor
            .HasIndex(nameof(ISearchableEntity.SearchVector))
            .HasMethod("GIN");
        }