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

31 lines
857 B
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 大名科技(天津)有限公司版权所有 电话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;
}
}