DigitalFactory/Admin.NET/Admin.NET.Core/Service/APIJSON/TableMapper.cs

31 lines
857 B
C#
Raw Normal View History

2024-03-18 01:36:19 +00:00
// 大名科技(天津)有限公司版权所有 电话18020030720 QQ515096995
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
namespace Admin.NET.Core.Service;
/// <summary>
/// 表名映射
/// </summary>
public class TableMapper : ITransient
{
private readonly Dictionary<string, string> _options = new(StringComparer.OrdinalIgnoreCase);
public TableMapper(IOptions<Dictionary<string, string>> options)
{
foreach (var item in options.Value)
{
_options.Add(item.Key, item.Value);
}
}
/// <summary>
/// 获取表别名
/// </summary>
/// <param name="oldname"></param>
/// <returns></returns>
public string GetTableName(string oldname)
{
return _options.ContainsKey(oldname) ? _options[oldname] : oldname;
}
}