Browse Source

Code optimization

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
14412a45bd
  1. 9
      Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlBuilder.cs
  2. 9
      Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerBuilder.cs
  3. 5
      Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteBuilder.cs

9
Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlBuilder.cs

@ -9,15 +9,16 @@ namespace SqlSugar
public override string GetTranslationTableName(string name)
{
Check.ArgumentNullException(name, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
if (name.IsContainsIn("`", "(", ")"))
{
return name;
}
var context = this.Context;
var mappingInfo = context
.MappingTables
.FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
name = (mappingInfo == null ? name : mappingInfo.DbTableName);
if (name.Contains("`"))
return name;
else
return "`" + name + "`";
return "`" + name + "`";
}
public override string GetTranslationColumnName(string entityName, string propertyName)
{

9
Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerBuilder.cs

@ -12,15 +12,16 @@ namespace SqlSugar
public override string GetTranslationTableName(string name)
{
Check.ArgumentNullException(name, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
if (name.IsContainsIn("(", ")", "["))
{
return name;
}
var context = this.Context;
var mappingInfo = context
.MappingTables
.FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
name = (mappingInfo == null ? name : mappingInfo.DbTableName);
if (name.Contains("["))
return name;
else
return "[" + name + "]";
return "[" + name + "]";
}
public override string GetTranslationColumnName(string entityName, string propertyName)
{

5
Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteBuilder.cs

@ -9,8 +9,11 @@ namespace SqlSugar
public override string GetTranslationTableName(string name)
{
if (name.Contains("`")) return name;
Check.ArgumentNullException(name, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
if (name.IsContainsIn("`", "(", ")"))
{
return name;
}
var context = this.Context;
var mappingInfo = context
.MappingTables

Loading…
Cancel
Save