Skip to content

Commit e289bfa

Browse files
authored
API review follow-ups: rename full-text/vector builder methods, remove IndexBuilder extensions, collapse TVF overloads (#38027)
Part of #37993
1 parent 134fd04 commit e289bfa

16 files changed

Lines changed: 195 additions & 534 deletions

src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,6 @@ private static readonly MethodInfo FullTextCatalogIsAccentSensitiveMethodInfo
159159
= typeof(SqlServerFullTextCatalogBuilder).GetRuntimeMethod(
160160
nameof(SqlServerFullTextCatalogBuilder.IsAccentSensitive), [typeof(bool)])!;
161161

162-
private static readonly MethodInfo IndexHasFullTextKeyIndexMethodInfo
163-
= typeof(SqlServerIndexBuilderExtensions).GetRuntimeMethod(
164-
nameof(SqlServerIndexBuilderExtensions.HasFullTextKeyIndex), [typeof(IndexBuilder), typeof(string)])!;
165-
166-
private static readonly MethodInfo IndexHasFullTextCatalogMethodInfo
167-
= typeof(SqlServerIndexBuilderExtensions).GetRuntimeMethod(
168-
nameof(SqlServerIndexBuilderExtensions.HasFullTextCatalog), [typeof(IndexBuilder), typeof(string)])!;
169-
170-
private static readonly MethodInfo IndexHasFullTextChangeTrackingMethodInfo
171-
= typeof(SqlServerIndexBuilderExtensions).GetRuntimeMethod(
172-
nameof(SqlServerIndexBuilderExtensions.HasFullTextChangeTracking), [typeof(IndexBuilder), typeof(FullTextChangeTracking)])!;
173-
174-
private static readonly MethodInfo IndexHasFullTextLanguageMethodInfo
175-
= typeof(SqlServerIndexBuilderExtensions).GetRuntimeMethod(
176-
nameof(SqlServerIndexBuilderExtensions.HasFullTextLanguage), [typeof(IndexBuilder), typeof(string), typeof(string)])!;
177-
178162
#endregion MethodInfos
179163

180164
/// <summary>
@@ -469,30 +453,6 @@ protected override bool IsHandledByConvention(IProperty property, IAnnotation an
469453
_ => null
470454
};
471455

472-
/// <summary>
473-
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
474-
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
475-
/// any release. You should only use it directly in your code with extreme caution and knowing that
476-
/// doing so can result in application failures when updating to a new Entity Framework Core release.
477-
/// </summary>
478-
public override IReadOnlyList<MethodCallCodeFragment> GenerateFluentApiCalls(
479-
IIndex index,
480-
IDictionary<string, IAnnotation> annotations)
481-
{
482-
var fragments = new List<MethodCallCodeFragment>(base.GenerateFluentApiCalls(index, annotations));
483-
484-
if (annotations.Remove(SqlServerAnnotationNames.FullTextLanguages, out var languagesAnnotation)
485-
&& languagesAnnotation.Value is Dictionary<string, string> languages)
486-
{
487-
foreach (var (propertyName, language) in languages.OrderBy(l => l.Key))
488-
{
489-
fragments.Add(new MethodCallCodeFragment(IndexHasFullTextLanguageMethodInfo, propertyName, language));
490-
}
491-
}
492-
493-
return fragments;
494-
}
495-
496456
/// <summary>
497457
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
498458
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -515,13 +475,6 @@ public override IReadOnlyList<MethodCallCodeFragment> GenerateFluentApiCalls(
515475
SqlServerAnnotationNames.DataCompression
516476
=> new MethodCallCodeFragment(IndexUseDataCompressionMethodInfo, annotation.Value),
517477

518-
SqlServerAnnotationNames.FullTextIndex
519-
=> new MethodCallCodeFragment(IndexHasFullTextKeyIndexMethodInfo, annotation.Value),
520-
SqlServerAnnotationNames.FullTextCatalog
521-
=> new MethodCallCodeFragment(IndexHasFullTextCatalogMethodInfo, annotation.Value),
522-
SqlServerAnnotationNames.FullTextChangeTracking
523-
=> new MethodCallCodeFragment(IndexHasFullTextChangeTrackingMethodInfo, annotation.Value),
524-
525478
_ => null
526479
};
527480

src/EFCore.SqlServer/Extensions/FullTextSearchResult.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
namespace Microsoft.EntityFrameworkCore;
4+
namespace Microsoft.EntityFrameworkCore.Query;
55

66
/// <summary>
77
/// Represents the results from a call to
8-
/// <see cref="SqlServerQueryableExtensions.FreeTextTable{T, TKey}(DbSet{T}, Expression{Func{T, object}}, string, string?, int?)" /> or
9-
/// <see cref="SqlServerQueryableExtensions.ContainsTable{T, TKey}(DbSet{T}, Expression{Func{T, object}}, string, string?, int?)" />.
8+
/// <see cref="SqlServerQueryableExtensions.FreeTextTable{T, TKey}(DbSet{T}, string, Expression{Func{T, object}}?, string?, int?)" /> or
9+
/// <see cref="SqlServerQueryableExtensions.ContainsTable{T, TKey}(DbSet{T}, string, Expression{Func{T, object}}?, string?, int?)" />.
1010
/// </summary>
1111
/// <typeparam name="TKey">The type of the full-text key column for the table being searched.</typeparam>
1212
public readonly struct FullTextSearchResult<TKey>(TKey key, int rank)

src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs

Lines changed: 14 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -572,54 +572,20 @@ public static bool CanSetDataCompression(
572572
/// for more information on SQL Server full-text search.
573573
/// </remarks>
574574
/// <param name="indexBuilder">The builder for the index being configured.</param>
575-
/// <param name="keyIndexName">The name of the KEY INDEX.</param>
576-
/// <returns>A builder to further configure the index.</returns>
577-
public static IndexBuilder HasFullTextKeyIndex(this IndexBuilder indexBuilder, string keyIndexName)
578-
{
579-
Check.NotEmpty(keyIndexName);
580-
581-
indexBuilder.Metadata.SetFullTextKeyIndex(keyIndexName);
582-
583-
return indexBuilder;
584-
}
585-
586-
/// <summary>
587-
/// Configures the KEY INDEX for the full-text index when targeting SQL Server.
588-
/// </summary>
589-
/// <remarks>
590-
/// See <see href="https://learn.microsoft.com/sql/relational-databases/search/full-text-search">Full-Text Search</see>
591-
/// for more information on SQL Server full-text search.
592-
/// </remarks>
593-
/// <param name="indexBuilder">The builder for the index being configured.</param>
594-
/// <param name="keyIndexName">The name of the KEY INDEX.</param>
595-
/// <returns>A builder to further configure the index.</returns>
596-
public static IndexBuilder<TEntity> HasFullTextKeyIndex<TEntity>(
597-
this IndexBuilder<TEntity> indexBuilder,
598-
string keyIndexName)
599-
=> (IndexBuilder<TEntity>)HasFullTextKeyIndex((IndexBuilder)indexBuilder, keyIndexName);
600-
601-
/// <summary>
602-
/// Configures the KEY INDEX for the full-text index when targeting SQL Server.
603-
/// </summary>
604-
/// <remarks>
605-
/// See <see href="https://learn.microsoft.com/sql/relational-databases/search/full-text-search">Full-Text Search</see>
606-
/// for more information on SQL Server full-text search.
607-
/// </remarks>
608-
/// <param name="indexBuilder">The builder for the index being configured.</param>
609-
/// <param name="keyIndexName">The name of the KEY INDEX.</param>
575+
/// <param name="keyIndex">The name of the KEY INDEX.</param>
610576
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
611577
/// <returns>
612578
/// The same builder instance if the configuration was applied,
613579
/// <see langword="null" /> otherwise.
614580
/// </returns>
615581
public static IConventionIndexBuilder? HasFullTextKeyIndex(
616582
this IConventionIndexBuilder indexBuilder,
617-
string? keyIndexName,
583+
string? keyIndex,
618584
bool fromDataAnnotation = false)
619585
{
620-
if (indexBuilder.CanSetFullTextKeyIndex(keyIndexName, fromDataAnnotation))
586+
if (indexBuilder.CanSetFullTextKeyIndex(keyIndex, fromDataAnnotation))
621587
{
622-
indexBuilder.Metadata.SetFullTextKeyIndex(keyIndexName, fromDataAnnotation);
588+
indexBuilder.Metadata.SetFullTextKeyIndex(keyIndex, fromDataAnnotation);
623589

624590
return indexBuilder;
625591
}
@@ -635,48 +601,14 @@ public static IndexBuilder<TEntity> HasFullTextKeyIndex<TEntity>(
635601
/// for more information on SQL Server full-text search.
636602
/// </remarks>
637603
/// <param name="indexBuilder">The builder for the index being configured.</param>
638-
/// <param name="keyIndexName">The name of the KEY INDEX.</param>
604+
/// <param name="keyIndex">The name of the KEY INDEX.</param>
639605
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
640606
/// <returns><see langword="true" /> if the index can be configured with the specified KEY INDEX when targeting SQL Server.</returns>
641607
public static bool CanSetFullTextKeyIndex(
642608
this IConventionIndexBuilder indexBuilder,
643-
string? keyIndexName,
609+
string? keyIndex,
644610
bool fromDataAnnotation = false)
645-
=> indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.FullTextIndex, keyIndexName, fromDataAnnotation);
646-
647-
/// <summary>
648-
/// Configures the full-text catalog for the full-text index when targeting SQL Server.
649-
/// </summary>
650-
/// <remarks>
651-
/// See <see href="https://learn.microsoft.com/sql/relational-databases/search/full-text-search">Full-Text Search</see>
652-
/// for more information on SQL Server full-text search.
653-
/// </remarks>
654-
/// <param name="indexBuilder">The builder for the index being configured.</param>
655-
/// <param name="catalogName">The name of the full-text catalog.</param>
656-
/// <returns>A builder to further configure the index.</returns>
657-
public static IndexBuilder HasFullTextCatalog(this IndexBuilder indexBuilder, string catalogName)
658-
{
659-
Check.NotEmpty(catalogName);
660-
661-
indexBuilder.Metadata.SetFullTextCatalog(catalogName);
662-
663-
return indexBuilder;
664-
}
665-
666-
/// <summary>
667-
/// Configures the full-text catalog for the full-text index when targeting SQL Server.
668-
/// </summary>
669-
/// <remarks>
670-
/// See <see href="https://learn.microsoft.com/sql/relational-databases/search/full-text-search">Full-Text Search</see>
671-
/// for more information on SQL Server full-text search.
672-
/// </remarks>
673-
/// <param name="indexBuilder">The builder for the index being configured.</param>
674-
/// <param name="catalogName">The name of the full-text catalog.</param>
675-
/// <returns>A builder to further configure the index.</returns>
676-
public static IndexBuilder<TEntity> HasFullTextCatalog<TEntity>(
677-
this IndexBuilder<TEntity> indexBuilder,
678-
string catalogName)
679-
=> (IndexBuilder<TEntity>)HasFullTextCatalog((IndexBuilder)indexBuilder, catalogName);
611+
=> indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.FullTextIndex, keyIndex, fromDataAnnotation);
680612

681613
/// <summary>
682614
/// Configures the full-text catalog for the full-text index when targeting SQL Server.
@@ -686,20 +618,20 @@ public static IndexBuilder<TEntity> HasFullTextCatalog<TEntity>(
686618
/// for more information on SQL Server full-text search.
687619
/// </remarks>
688620
/// <param name="indexBuilder">The builder for the index being configured.</param>
689-
/// <param name="catalogName">The name of the full-text catalog.</param>
621+
/// <param name="catalog">The name of the full-text catalog.</param>
690622
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
691623
/// <returns>
692624
/// The same builder instance if the configuration was applied,
693625
/// <see langword="null" /> otherwise.
694626
/// </returns>
695627
public static IConventionIndexBuilder? HasFullTextCatalog(
696628
this IConventionIndexBuilder indexBuilder,
697-
string? catalogName,
629+
string? catalog,
698630
bool fromDataAnnotation = false)
699631
{
700-
if (indexBuilder.CanSetFullTextCatalog(catalogName, fromDataAnnotation))
632+
if (indexBuilder.CanSetFullTextCatalog(catalog, fromDataAnnotation))
701633
{
702-
indexBuilder.Metadata.SetFullTextCatalog(catalogName, fromDataAnnotation);
634+
indexBuilder.Metadata.SetFullTextCatalog(catalog, fromDataAnnotation);
703635

704636
return indexBuilder;
705637
}
@@ -715,46 +647,14 @@ public static IndexBuilder<TEntity> HasFullTextCatalog<TEntity>(
715647
/// for more information on SQL Server full-text search.
716648
/// </remarks>
717649
/// <param name="indexBuilder">The builder for the index being configured.</param>
718-
/// <param name="catalogName">The name of the full-text catalog.</param>
650+
/// <param name="catalog">The name of the full-text catalog.</param>
719651
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
720652
/// <returns><see langword="true" /> if the index can be configured with the specified full-text catalog when targeting SQL Server.</returns>
721653
public static bool CanSetFullTextCatalog(
722654
this IConventionIndexBuilder indexBuilder,
723-
string? catalogName,
655+
string? catalog,
724656
bool fromDataAnnotation = false)
725-
=> indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.FullTextCatalog, catalogName, fromDataAnnotation);
726-
727-
/// <summary>
728-
/// Configures the change tracking mode for the full-text index when targeting SQL Server.
729-
/// </summary>
730-
/// <remarks>
731-
/// See <see href="https://learn.microsoft.com/sql/relational-databases/search/full-text-search">Full-Text Search</see>
732-
/// for more information on SQL Server full-text search.
733-
/// </remarks>
734-
/// <param name="indexBuilder">The builder for the index being configured.</param>
735-
/// <param name="changeTracking">The change tracking mode.</param>
736-
/// <returns>A builder to further configure the index.</returns>
737-
public static IndexBuilder HasFullTextChangeTracking(this IndexBuilder indexBuilder, FullTextChangeTracking changeTracking)
738-
{
739-
indexBuilder.Metadata.SetFullTextChangeTracking(changeTracking);
740-
741-
return indexBuilder;
742-
}
743-
744-
/// <summary>
745-
/// Configures the change tracking mode for the full-text index when targeting SQL Server.
746-
/// </summary>
747-
/// <remarks>
748-
/// See <see href="https://learn.microsoft.com/sql/relational-databases/search/full-text-search">Full-Text Search</see>
749-
/// for more information on SQL Server full-text search.
750-
/// </remarks>
751-
/// <param name="indexBuilder">The builder for the index being configured.</param>
752-
/// <param name="changeTracking">The change tracking mode.</param>
753-
/// <returns>A builder to further configure the index.</returns>
754-
public static IndexBuilder<TEntity> HasFullTextChangeTracking<TEntity>(
755-
this IndexBuilder<TEntity> indexBuilder,
756-
FullTextChangeTracking changeTracking)
757-
=> (IndexBuilder<TEntity>)HasFullTextChangeTracking((IndexBuilder)indexBuilder, changeTracking);
657+
=> indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.FullTextCatalog, catalog, fromDataAnnotation);
758658

759659
/// <summary>
760660
/// Configures the change tracking mode for the full-text index when targeting SQL Server.
@@ -805,44 +705,6 @@ public static bool CanSetFullTextChangeTracking(
805705
bool fromDataAnnotation = false)
806706
=> indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.FullTextChangeTracking, changeTracking, fromDataAnnotation);
807707

808-
/// <summary>
809-
/// Configures the language for a specific property in the full-text index when targeting SQL Server.
810-
/// </summary>
811-
/// <remarks>
812-
/// See <see href="https://learn.microsoft.com/sql/relational-databases/search/full-text-search">Full-Text Search</see>
813-
/// for more information on SQL Server full-text search.
814-
/// </remarks>
815-
/// <param name="indexBuilder">The builder for the index being configured.</param>
816-
/// <param name="propertyName">The name of the property.</param>
817-
/// <param name="language">The language term (e.g. "English", "1033").</param>
818-
/// <returns>A builder to further configure the index.</returns>
819-
public static IndexBuilder HasFullTextLanguage(this IndexBuilder indexBuilder, string propertyName, string language)
820-
{
821-
Check.NotEmpty(propertyName);
822-
Check.NotEmpty(language);
823-
824-
indexBuilder.Metadata.SetFullTextLanguage(propertyName, language);
825-
826-
return indexBuilder;
827-
}
828-
829-
/// <summary>
830-
/// Configures the language for a specific property in the full-text index when targeting SQL Server.
831-
/// </summary>
832-
/// <remarks>
833-
/// See <see href="https://learn.microsoft.com/sql/relational-databases/search/full-text-search">Full-Text Search</see>
834-
/// for more information on SQL Server full-text search.
835-
/// </remarks>
836-
/// <param name="indexBuilder">The builder for the index being configured.</param>
837-
/// <param name="propertyName">The name of the property.</param>
838-
/// <param name="language">The language term (e.g. "English", "1033").</param>
839-
/// <returns>A builder to further configure the index.</returns>
840-
public static IndexBuilder<TEntity> HasFullTextLanguage<TEntity>(
841-
this IndexBuilder<TEntity> indexBuilder,
842-
string propertyName,
843-
string language)
844-
=> (IndexBuilder<TEntity>)HasFullTextLanguage((IndexBuilder)indexBuilder, propertyName, language);
845-
846708
/// <summary>
847709
/// Configures the languages for properties in the full-text index when targeting SQL Server.
848710
/// </summary>

0 commit comments

Comments
 (0)