/// <summary>
            /// Gets the name of the table in the database for the specified type,
            /// using the configured <see cref="ITableNameResolver"/>.
            /// </summary>
            /// <param name="type">The <see cref="Type"/> to get the table name for.</param>
            /// <param name="sqlBuilder">The SQL builder instance.</param>
            /// <returns>The table name in the database for <paramref name="type"/>.</returns>
            public static string Table(Type type, ISqlBuilder sqlBuilder)
            {
                var key = $"{sqlBuilder.GetType()}.{type}";

                if (!_typeTableNameCache.TryGetValue(key, out var name))
                {
                    name = sqlBuilder.QuoteIdentifier(TableNameResolver.ResolveTableName(type));
                    _typeTableNameCache.TryAdd(key, name);
                }

                LogReceived?.Invoke($"Resolved table name '{name}' for '{type}'");
                return(name);
            }
Esempio n. 2
0
 protected string TableNameFor(Type type)
 {
     return(TableNameResolver.Resolve(type));
 }
Esempio n. 3
0
 public static void SetupBulkCopyByDataType <TData>(this SqlBulkCopy bulkCopy, TableNameResolver nameResolver)
 {
     bulkCopy.MapAllPropertiesAsColumns <TData>();
     bulkCopy.DestinationTableName = nameResolver == null
                         ? DataTypeHelper.GetSqlTableName <TData>()
                         : nameResolver.GetName(DataTypeHelper.GetSqlTableName <TData>());
 }
 public CachingNameResolver(INameFormatter nameFormatter)
 {
     _columnNameResolver = new ColumnNameResolver(nameFormatter);
     _tableNameResolver  = new TableNameResolver(nameFormatter);
 }