示例#1
0
        /// <summary>
        /// Get the PTable Name for an Entity Type.
        /// </summary>
        /// <param name="type">Entity Type.</param>
        /// <returns>Table Name.</returns>
        protected string GetTableName(Type type)
        {
            var cacheHit = TableNames.TryGetValue(type, out string tableName);

            if (!cacheHit)
            {
                tableName = Context.Model.FindEntityType(type).GetTableName();

                TableNames.TryAdd(type, tableName);
            }

            return(tableName);
        }
        //Gets the table name for this type
        //For Get(id) and Delete(id) we don't have an entity, just the type so this method is used
        //Use dynamic type to be able to handle both our Table-attribute and the DataAnnotation
        //Uses class name by default and overrides if the class has a Table attribute
        private static string GetTableName(Type type)
        {
            string tableName;

            if (TableNames.TryGetValue(type, out tableName))
            {
                return(tableName);
            }

            tableName = _tableNameResolver.ResolveTableName(type);
            TableNames.AddOrUpdate(type, tableName, (t, v) => tableName);
            return(tableName);
        }
        //Gets the table name for this type
        //For Get(id) and Delete(id) we don't have an entity, just the type so this method is used
        //Use dynamic type to be able to handle both our Table-attribute and the DataAnnotation
        //Uses class name by default and overrides if the class has a Table attribute
        private string GetTableName(Type type)
        {
            string tableName;

            if (TableNames.TryGetValue(type, out tableName))
            {
                return(tableName);
            }

            tableName        = _tableNameResolver.ResolveTableName(type);
            TableNames[type] = tableName;

            return(tableName);
        }