/// <summary> /// 获取模型的Oracle特定元数据。 /// </summary> /// <param name="model"> 获取元数据的模型。 </param> /// <returns> 模型的Oracle特定元数据 </returns> public static OracleModelAnnotations Oracle([NotNull] this IMutableModel model) { Check.NotNull(model, nameof(model)); return (OracleModelAnnotations)((IModel)model).Oracle(); }
/// <summary> /// Sets the default schema. /// </summary> /// <param name="model"> The model to set the default schema for. </param> /// <param name="value"> The value to set. </param> public static void SetDefaultSchema([NotNull] this IMutableModel model, [CanBeNull] string value) => model.SetOrRemoveAnnotation( RelationalAnnotationNames.DefaultSchema, Check.NullButNotEmpty(value, nameof(value)));
/// <summary> /// Sets the name of the parent property to which the entity type is mapped. /// </summary> /// <param name="entityType"> The entity type to set the containing property name for. </param> /// <param name="name"> The name to set. </param> public static void SetContainingPropertyName([NotNull] this IMutableEntityType entityType, [CanBeNull] string name) => entityType.SetOrRemoveAnnotation( CosmosAnnotationNames.PropertyName, Check.NullButNotEmpty(name, nameof(name)));
/// <summary> /// Removes the <see cref="IMutableDbFunction" /> that is mapped to the method represented by the given /// <see cref="MethodInfo" />. /// </summary> /// <param name="model"> The model to find the function in. </param> /// <param name="name"> The model name of the function. </param> /// <returns> The removed <see cref="IMutableDbFunction" /> or <c>null</c> if the method is not mapped. </returns> public static IMutableDbFunction RemoveDbFunction([NotNull] this IMutableModel model, [NotNull] string name) => DbFunction.RemoveDbFunction( Check.NotNull(model, nameof(model)), Check.NotNull(name, nameof(name)));
/// <summary> /// Returns all <see cref="IConventionDbFunction" />s contained in the model. /// </summary> /// <param name="model"> The model to get the functions in. </param> public static IEnumerable<IConventionDbFunction> GetDbFunctions([NotNull] this IConventionModel model) => DbFunction.GetDbFunctions((Model)Check.NotNull(model, nameof(model)));
/// <summary> /// Creates an <see cref="IMutableDbFunction" /> mapped to the given method. /// </summary> /// <param name="model"> The model to add the function to. </param> /// <param name="methodInfo"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param> /// <returns> The new <see cref="IMutableDbFunction" />. </returns> public static IMutableDbFunction AddDbFunction([NotNull] this IMutableModel model, [NotNull] MethodInfo methodInfo) => DbFunction.AddDbFunction( model, Check.NotNull(methodInfo, nameof(methodInfo)), ConfigurationSource.Explicit);
/// <summary> /// Creates an <see cref="IMutableDbFunction" />. /// </summary> /// <param name="model"> The model to add the function to. </param> /// <param name="name"> The model name of the function. </param> /// <param name="returnType"> The function return type. </param> /// <returns> The new <see cref="IMutableDbFunction" />. </returns> public static IMutableDbFunction AddDbFunction( [NotNull] this IMutableModel model, [NotNull] string name, [NotNull] Type returnType) => DbFunction.AddDbFunction( model, Check.NotNull(name, nameof(name)), returnType, ConfigurationSource.Explicit);
/// <summary> /// Sets the SQL expression that is used as the computed value for the column this property is mapped to. /// </summary> /// <param name="property"> The property. </param> /// <param name="value"> The value to set. </param> public static void SetComputedColumnSql([NotNull] this IMutableProperty property, [CanBeNull] string value) => property.SetOrRemoveAnnotation( RelationalAnnotationNames.ComputedColumnSql, Check.NullButNotEmpty(value, nameof(value)));
/// <summary> /// Sets the SQL expression that is used as the computed value for the column this property is mapped to. /// </summary> /// <param name="property"> The property. </param> /// <param name="value"> The value to set. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> public static void SetComputedColumnSql( [NotNull] this IConventionProperty property, [CanBeNull] string value, bool fromDataAnnotation = false) => property.SetOrRemoveAnnotation( RelationalAnnotationNames.ComputedColumnSql, Check.NullButNotEmpty(value, nameof(value)), fromDataAnnotation);
/// <summary> /// Sets the index filter expression. /// </summary> /// <param name="index"> The index. </param> /// <param name="value"> The value to set. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> public static void SetFilter([NotNull] this IConventionIndex index, [CanBeNull] string value, bool fromDataAnnotation = false) => index.SetOrRemoveAnnotation( RelationalAnnotationNames.Filter, Check.NullButNotEmpty(value, nameof(value)), fromDataAnnotation);
/// <summary> /// Sets the view column to which the property is mapped. /// </summary> /// <param name="property"> The property. </param> /// <param name="name"> The name to set. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> public static void SetViewColumnName( [NotNull] this IConventionProperty property, [CanBeNull] string name, bool fromDataAnnotation = false) => property.SetOrRemoveAnnotation( RelationalAnnotationNames.ViewColumnName, Check.NullButNotEmpty(name, nameof(name)), fromDataAnnotation);
/// <summary> /// Sets the index filter expression. /// </summary> /// <param name="index"> The index. </param> /// <param name="value"> The value to set. </param> public static void SetFilter([NotNull] this IMutableIndex index, [CanBeNull] string value) => index.SetOrRemoveAnnotation( RelationalAnnotationNames.Filter, Check.NullButNotEmpty(value, nameof(value)));
/// <summary> /// Sets the index name. /// </summary> /// <param name="index"> The index. </param> /// <param name="name"> The value to set. </param> public static void SetName([NotNull] this IMutableIndex index, [CanBeNull] string name) => index.SetOrRemoveAnnotation( RelationalAnnotationNames.Name, Check.NullButNotEmpty(name, nameof(name)));
/// <summary> /// 获取模型的Oracle特定元数据 /// </summary> /// <param name="model"> 获取元数据的模型 </param> /// <returns> 模型的Oracle特定元数据 </returns> public static IOracleModelAnnotations Oracle([NotNull] this IModel model) { Check.NotNull(model, nameof(model)); return new OracleModelAnnotations(model); }
/// <summary> /// Finds a <see cref="IDbFunction" /> that is mapped to the method represented by the given <see cref="MethodInfo" />. /// </summary> /// <param name="model"> The model to find the function in. </param> /// <param name="method"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param> /// <returns> The <see cref="IDbFunction" /> or <c>null</c> if the method is not mapped. </returns> public static IDbFunction FindDbFunction([NotNull] this IModel model, [NotNull] MethodInfo method) => DbFunction.FindDbFunction( Check.NotNull(model, nameof(model)), Check.NotNull(method, nameof(method)));
/// <summary> /// Sets the column to which the property is mapped. /// </summary> /// <param name="property"> The property. </param> /// <param name="name"> The name to set. </param> public static void SetColumnName([NotNull] this IMutableProperty property, [CanBeNull] string name) => property.SetOrRemoveAnnotation( RelationalAnnotationNames.ColumnName, Check.NullButNotEmpty(name, nameof(name)));
/// <summary> /// Finds an <see cref="IDbFunction" /> that is mapped to the method represented by the given name. /// </summary> /// <param name="model"> The model to find the function in. </param> /// <param name="name"> The model name of the function. </param> /// <returns> The <see cref="IDbFunction" /> or <c>null</c> if the method is not mapped. </returns> public static IDbFunction FindDbFunction([NotNull] this IModel model, [NotNull] string name) => DbFunction.FindDbFunction( Check.NotNull(model, nameof(model)), Check.NotNull(name, nameof(name)));
/// <summary> /// Sets the name of the container to which the entity type is mapped. /// </summary> /// <param name="entityType"> The entity type to set the container name for. </param> /// <param name="name"> The name to set. </param> public static void SetContainer(this IMutableEntityType entityType, string?name) => entityType.SetOrRemoveAnnotation( CosmosAnnotationNames.ContainerName, Check.NullButNotEmpty(name, nameof(name)));
/// <summary> /// Creates an <see cref="IConventionDbFunction" /> mapped to the given method. /// </summary> /// <param name="model"> The model to add the function to. </param> /// <param name="methodInfo"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> The new <see cref="IConventionDbFunction" />. </returns> public static IConventionDbFunction AddDbFunction( [NotNull] this IConventionModel model, [NotNull] MethodInfo methodInfo, bool fromDataAnnotation = false) => DbFunction.AddDbFunction( (IMutableModel)model, Check.NotNull(methodInfo, nameof(methodInfo)), fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
/// <summary> /// Returns the maximum length allowed for store identifiers. /// </summary> /// <param name="model"> The model to get the maximum identifier length for. </param> /// <returns> The maximum identifier length. </returns> public static int GetMaxIdentifierLength([NotNull] this IModel model) => (int?)Check.NotNull(model, nameof(model))[RelationalAnnotationNames.MaxIdentifierLength] ?? short.MaxValue;
/// <summary> /// Removes the <see cref="IMutableDbFunction" /> that is mapped to the method represented by the given /// <see cref="MethodInfo" />. /// </summary> /// <param name="model"> The model to find the function in. </param> /// <param name="method"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param> /// <returns> The removed <see cref="IMutableDbFunction" /> or <c>null</c> if the method is not mapped. </returns> public static IMutableDbFunction RemoveDbFunction([NotNull] this IMutableModel model, [NotNull] MethodInfo method) => DbFunction.RemoveDbFunction( Check.NotNull(model, nameof(model)), Check.NotNull(method, nameof(method)));
/// <summary> /// Finds an <see cref="ISequence" /> with the given name. /// </summary> /// <param name="model"> The model to find the sequence in. </param> /// <param name="name"> The sequence name. </param> /// <param name="schema"> The schema that contains the sequence. </param> /// <returns> /// The <see cref="ISequence" /> or <c>null</c> if no sequence with the given name in /// the given schema was found. /// </returns> public static ISequence FindSequence([NotNull] this IModel model, [NotNull] string name, [CanBeNull] string schema = null) => Sequence.FindSequence( Check.NotNull(model, nameof(model)), Check.NotEmpty(name, nameof(name)), Check.NullButNotEmpty(schema, nameof(schema)));
/// <summary> /// Returns all <see cref="IDbFunction" />s contained in the model. /// </summary> /// <param name="model"> The model to get the functions in. </param> public static IEnumerable<IDbFunction> GetDbFunctions([NotNull] this IModel model) => DbFunction.GetDbFunctions(Check.NotNull(model, nameof(model)));
/// <summary> /// Removes the <see cref="IConventionSequence" /> with the given name. /// </summary> /// <param name="model"> The model to find the sequence in. </param> /// <param name="name"> The sequence name. </param> /// <param name="schema"> The schema that contains the sequence. </param> /// <returns> /// The removed <see cref="IConventionSequence" /> or <c>null</c> if no sequence with the given name in /// the given schema was found. /// </returns> public static IConventionSequence RemoveSequence( [NotNull] this IConventionModel model, [NotNull] string name, [CanBeNull] string schema = null) => Sequence.RemoveSequence((IMutableModel)Check.NotNull(model, nameof(model)), name, schema);
/// <summary> /// Returns the default schema to use for the model, or <c>null</c> if none has been set. /// </summary> /// <param name="model"> The model to get the default schema for. </param> /// <returns> The default schema. </returns> public static string GetDefaultSchema([NotNull] this IModel model) => (string)Check.NotNull(model, nameof(model))[RelationalAnnotationNames.DefaultSchema];
/// <summary> /// Returns all <see cref="IMutableSequence" />s contained in the model. /// </summary> /// <param name="model"> The model to get the sequences in. </param> public static IEnumerable<IMutableSequence> GetSequences([NotNull] this IMutableModel model) => Sequence.GetSequences(Check.NotNull(model, nameof(model)));
/// <summary> /// Returns a value indicating whether the foreign key constraint name can be set for this relationship /// from the current configuration source /// </summary> /// <param name="relationship"> The builder being used to configure the relationship. </param> /// <param name="name"> The name of the foreign key constraint. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <c>true</c> if the configuration can be applied. </returns> public static bool CanSetConstraintName( [NotNull] this IConventionRelationshipBuilder relationship, [CanBeNull] string name, bool fromDataAnnotation = false) => Check.NotNull(relationship, nameof(relationship)) .CanSetAnnotation(RelationalAnnotationNames.Name, name, fromDataAnnotation);
/// <summary> /// Returns all <see cref="IConventionSequence" />s contained in the model. /// </summary> /// <param name="model"> The model to get the sequences in. </param> public static IEnumerable<IConventionSequence> GetSequences([NotNull] this IConventionModel model) => Sequence.GetSequences(Check.NotNull(model, nameof(model)));
/// <summary> /// Sets the name of the parent property to which the entity type is mapped. /// </summary> /// <param name="entityType"> The entity type to set the containing property name for. </param> /// <param name="name"> The name to set. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> public static void SetContainingPropertyName( [NotNull] this IConventionEntityType entityType, [CanBeNull] string name, bool fromDataAnnotation = false) => entityType.SetOrRemoveAnnotation( CosmosAnnotationNames.PropertyName, Check.NullButNotEmpty(name, nameof(name)), fromDataAnnotation);
/// <summary> /// 获取属性的Oracle特定元数据。 /// </summary> /// <param name="property"> 要为其获取元数据的属性 </param> /// <returns> 属性的Oracle特定元数据 </returns> public static IOraclePropertyAnnotations Oracle([NotNull] this IProperty property) { Check.NotNull(property, nameof(property)); return new OraclePropertyAnnotations(property); }