/// <summary> /// Returns the database schema that contains the mapped view. /// </summary> /// <param name="entityType">The entity type to get the view schema for.</param> /// <returns>The database schema that contains the mapped view.</returns> public static string?GetViewSchema(this IReadOnlyEntityType entityType) { var schemaAnnotation = entityType.FindAnnotation(RelationalAnnotationNames.ViewSchema); if (schemaAnnotation != null) { return((string?)schemaAnnotation.Value ?? GetDefaultViewSchema(entityType)); } return(entityType.BaseType != null ? entityType.GetRootType().GetViewSchema() : GetDefaultViewSchema(entityType)); }
/// <summary> /// Returns the name of the function to which the entity type is mapped or <see langword="null" /> if not mapped to a function. /// </summary> /// <param name="entityType">The entity type to get the function name for.</param> /// <returns>The name of the function to which the entity type is mapped.</returns> public static string?GetFunctionName(this IReadOnlyEntityType entityType) { var nameAnnotation = (string?)entityType[RelationalAnnotationNames.FunctionName]; if (nameAnnotation != null) { return(nameAnnotation); } if (entityType.BaseType != null) { return(entityType.GetRootType().GetFunctionName()); } return(null); }
/// <summary> /// Returns the SQL string used to provide data for the entity type or <see langword="null" /> if not mapped to a SQL string. /// </summary> /// <param name="entityType">The entity type.</param> /// <returns>The SQL string used to provide data for the entity type.</returns> public static string?GetSqlQuery(this IReadOnlyEntityType entityType) { var queryAnnotation = (string?)entityType[RelationalAnnotationNames.SqlQuery]; if (queryAnnotation != null) { return(queryAnnotation); } if (entityType.BaseType != null) { return(entityType.GetRootType().GetSqlQuery()); } return(null); }
/// <summary> /// Returns the name of the view to which the entity type is mapped or <see langword="null" /> if not mapped to a view. /// </summary> /// <param name="entityType">The entity type to get the view name for.</param> /// <returns>The name of the view to which the entity type is mapped.</returns> public static string?GetViewName(this IReadOnlyEntityType entityType) { var nameAnnotation = (string?)entityType[RelationalAnnotationNames.ViewName]; if (nameAnnotation != null) { return(nameAnnotation); } if (entityType.BaseType != null) { return(entityType.GetRootType().GetViewName()); } return(((entityType as IConventionEntityType)?.GetFunctionNameConfigurationSource() == null) #pragma warning disable CS0618 // Type or member is obsolete && (entityType as IConventionEntityType)?.GetDefiningQueryConfigurationSource() == null #pragma warning restore CS0618 // Type or member is obsolete && ((entityType as IConventionEntityType)?.GetSqlQueryConfigurationSource() == null) ? GetDefaultViewName(entityType) : null); }
public static string?GetTableName([NotNull] this IReadOnlyEntityType entityType) { var nameAnnotation = entityType.FindAnnotation(RelationalAnnotationNames.TableName); if (nameAnnotation != null) { return((string?)nameAnnotation.Value); } if (entityType.BaseType != null) { return(entityType.GetRootType().GetTableName()); } return((entityType as IConventionEntityType)?.GetViewNameConfigurationSource() == null && ((entityType as IConventionEntityType)?.GetFunctionNameConfigurationSource() == null) #pragma warning disable CS0618 // Type or member is obsolete && ((entityType as IConventionEntityType)?.GetDefiningQueryConfigurationSource() == null) #pragma warning restore CS0618 // Type or member is obsolete && ((entityType as IConventionEntityType)?.GetSqlQueryConfigurationSource() == null) ? GetDefaultTableName(entityType) : null); }
public static string?GetContainer([NotNull] this IReadOnlyEntityType entityType) => entityType.BaseType != null ? entityType.GetRootType().GetContainer() : (string?)entityType[CosmosAnnotationNames.ContainerName] ?? GetDefaultContainer(entityType);
/// <summary> /// Returns the name of the function to which the entity type is mapped or <see langword="null" /> if not mapped to a function. /// </summary> /// <param name="entityType">The entity type to get the function name for.</param> /// <returns>The name of the function to which the entity type is mapped.</returns> public static string?GetFunctionName(this IReadOnlyEntityType entityType) => (string?)entityType[RelationalAnnotationNames.FunctionName] ?? (entityType.BaseType != null ? entityType.GetRootType().GetFunctionName() : null);