|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements.
|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
| 4 | +using System.Diagnostics.CodeAnalysis; |
4 | 5 | using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;
|
5 | 6 |
|
6 | 7 | // ReSharper disable once CheckNamespace
|
@@ -883,6 +884,92 @@ public static bool CanSetDefaultTimeToLive(
|
883 | 884 | bool fromDataAnnotation = false)
|
884 | 885 | => entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.DefaultTimeToLive, seconds, fromDataAnnotation);
|
885 | 886 |
|
| 887 | + /// <summary> |
| 888 | + /// Configures a default language to use for full-text search at container scope. |
| 889 | + /// </summary> |
| 890 | + /// <remarks> |
| 891 | + /// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and |
| 892 | + /// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information and examples. |
| 893 | + /// </remarks> |
| 894 | + /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> |
| 895 | + /// <param name="language">The default language.</param> |
| 896 | + /// <returns>The same builder instance so that multiple calls can be chained.</returns> |
| 897 | + [Experimental(EFDiagnostics.CosmosFullTextSearchExperimental)] |
| 898 | + public static EntityTypeBuilder HasDefaultFullTextLanguage( |
| 899 | + this EntityTypeBuilder entityTypeBuilder, |
| 900 | + string? language) |
| 901 | + { |
| 902 | + entityTypeBuilder.Metadata.SetDefaultFullTextSearchLanguage(language); |
| 903 | + |
| 904 | + return entityTypeBuilder; |
| 905 | + } |
| 906 | + |
| 907 | + /// <summary> |
| 908 | + /// Configures a default language to use for full-text search at container scope. |
| 909 | + /// </summary> |
| 910 | + /// <remarks> |
| 911 | + /// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and |
| 912 | + /// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information and examples. |
| 913 | + /// </remarks> |
| 914 | + /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> |
| 915 | + /// <param name="language">The default language.</param> |
| 916 | + /// <returns>The same builder instance so that multiple calls can be chained.</returns> |
| 917 | + [Experimental(EFDiagnostics.CosmosFullTextSearchExperimental)] |
| 918 | + public static EntityTypeBuilder<TEntity> HasDefaultFullTextLanguage<TEntity>( |
| 919 | + this EntityTypeBuilder<TEntity> entityTypeBuilder, |
| 920 | + string? language) |
| 921 | + where TEntity : class |
| 922 | + => (EntityTypeBuilder<TEntity>)HasDefaultFullTextLanguage((EntityTypeBuilder)entityTypeBuilder, language); |
| 923 | + |
| 924 | + /// <summary> |
| 925 | + /// Configures a default language to use for full-text search at container scope. |
| 926 | + /// </summary> |
| 927 | + /// <remarks> |
| 928 | + /// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and |
| 929 | + /// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information and examples. |
| 930 | + /// </remarks> |
| 931 | + /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> |
| 932 | + /// <param name="language">The default language.</param> |
| 933 | + /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> |
| 934 | + /// <returns> |
| 935 | + /// The same builder instance if the configuration was applied, |
| 936 | + /// <see langword="null" /> otherwise. |
| 937 | + /// </returns> |
| 938 | + [Experimental(EFDiagnostics.CosmosFullTextSearchExperimental)] |
| 939 | + public static IConventionEntityTypeBuilder? HasDefaultFullTextLanguage( |
| 940 | + this IConventionEntityTypeBuilder entityTypeBuilder, |
| 941 | + string? language, |
| 942 | + bool fromDataAnnotation = false) |
| 943 | + { |
| 944 | + if (!entityTypeBuilder.CanSetDefaultFullTextLanguage(language, fromDataAnnotation)) |
| 945 | + { |
| 946 | + return null; |
| 947 | + } |
| 948 | + |
| 949 | + entityTypeBuilder.Metadata.SetDefaultFullTextSearchLanguage(language, fromDataAnnotation); |
| 950 | + |
| 951 | + return entityTypeBuilder; |
| 952 | + } |
| 953 | + |
| 954 | + /// <summary> |
| 955 | + /// Returns a value indicating whether the default full-text language can be set |
| 956 | + /// from the current configuration source |
| 957 | + /// </summary> |
| 958 | + /// <remarks> |
| 959 | + /// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and |
| 960 | + /// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information and examples. |
| 961 | + /// </remarks> |
| 962 | + /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> |
| 963 | + /// <param name="language">The default language.</param> |
| 964 | + /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> |
| 965 | + /// <returns><see langword="true" /> if the configuration can be applied.</returns> |
| 966 | + [Experimental(EFDiagnostics.CosmosFullTextSearchExperimental)] |
| 967 | + public static bool CanSetDefaultFullTextLanguage( |
| 968 | + this IConventionEntityTypeBuilder entityTypeBuilder, |
| 969 | + string? language, |
| 970 | + bool fromDataAnnotation = false) |
| 971 | + => entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.FullTextSearchDefaultLanguage, language, fromDataAnnotation); |
| 972 | + |
886 | 973 | /// <summary>
|
887 | 974 | /// Configures the manual provisioned throughput offering.
|
888 | 975 | /// </summary>
|
|
0 commit comments