SqlSugar/Src/Asp.Net/SqlSugar.Access/Access/CodeFirst/AccessCodeFirst.cs
2022-11-13 15:43:33 +08:00

39 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar.Access
{
public class AccessCodeFirst : CodeFirstProvider
{
protected override void ChangeKey(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
{
}
protected override string GetTableName(EntityInfo entityInfo)
{
var table= this.Context.EntityMaintenance.GetTableName(entityInfo.EntityName);
var tableArray = table.Split('.');
var noFormat = table.Split(']').Length==1;
if (tableArray.Length > 1 && noFormat)
{
var dbMain = new SqlServerDbMaintenance() { Context = this.Context };
var schmes = dbMain.GetSchemas();
if (!schmes.Any(it => it.EqualCase(tableArray.First())))
{
return tableArray.Last();
}
else
{
return dbMain.SqlBuilder.GetTranslationTableName(table);
}
}
else
{
return table;
}
}
}
}