コード例 #1
0
        /// <summary>
        ///     Creates an id for the store object that the given entity type is mapped to.
        /// </summary>
        /// <param name="entityType"> The entity type. </param>
        /// <param name="type"> The store object type. </param>
        /// <returns> The store object id. </returns>
        public static StoreObjectIdentifier?Create(IReadOnlyEntityType entityType, StoreObjectType type)
        {
            Check.NotNull(entityType, nameof(entityType));

            switch (type)
            {
            case StoreObjectType.Table:
                var tableName = entityType.GetTableName();
                return(tableName == null ? null : Table(tableName, entityType.GetSchema()));

            case StoreObjectType.View:
                var viewName = entityType.GetViewName();
                return(viewName == null ? null : View(viewName, entityType.GetViewSchema()));

            case StoreObjectType.SqlQuery:
                var query = entityType.GetSqlQuery();
                return(query == null ? null : SqlQuery(entityType));

            case StoreObjectType.Function:
                var functionName = entityType.GetFunctionName();
                return(functionName == null ? null : DbFunction(functionName));

            default:
                return(null);
            }
        }
コード例 #2
0
    /// <summary>
    ///     Returns the name of the view to which the entity type is mapped prepended by the schema
    ///     or <see langword="null" /> if not mapped to a view.
    /// </summary>
    /// <param name="entityType">The entity type to get the table name for.</param>
    /// <returns>The name of the table to which the entity type is mapped prepended by the schema.</returns>
    public static string?GetSchemaQualifiedViewName(this IReadOnlyEntityType entityType)
    {
        var viewName = entityType.GetViewName();

        if (viewName == null)
        {
            return(null);
        }

        var schema = entityType.GetViewSchema();

        return((string.IsNullOrEmpty(schema) ? "" : schema + ".") + viewName);
    }