Insert BUG

This commit is contained in:
sunkaixuan
2017-07-05 22:57:54 +08:00
parent 094400bcf8
commit e2441f480d
3 changed files with 20 additions and 2 deletions

View File

@@ -116,6 +116,8 @@ new List<SugarParameter>() {
insertObj.Name = null;
var t10 = db.Insertable(insertObj).ExecuteCommand();
var t11 = db.Insertable(new MyStudent() { Id = 1, Name = "张三" }).AS("Student").ToSql();
}
public SqlSugarClient GetInstance()
@@ -124,4 +126,10 @@ new List<SugarParameter>() {
return db;
}
}
public class MyStudent {
public int Id { get; set; }
public string Name { get; set; }
}
}

View File

@@ -59,6 +59,16 @@ namespace SqlSugar
return mappingInfo == null ? typeName : mappingInfo.DbTableName;
}
}
public string GetTableName(string entityName)
{
var typeName = entityName;
if (this.Context.MappingTables == null || this.Context.MappingTables.Count == 0) return typeName;
else
{
var mappingInfo = this.Context.MappingTables.SingleOrDefault(it => it.EntityName == typeName);
return mappingInfo == null ? typeName : mappingInfo.DbTableName;
}
}
public string GetEntityName(string tableName)
{
if (this.Context.MappingTables == null || this.Context.MappingTables.Count == 0) return tableName;

View File

@@ -201,7 +201,7 @@ namespace SqlSugar
{
if (this.Context.IsSystemTablesConfig)
{
return this.Context.DbMaintenance.GetPrimaries(this.EntityInfo.DbTableName);
return this.Context.DbMaintenance.GetPrimaries(this.Context.EntityProvider.GetTableName(this.EntityInfo.EntityName));
}
else
{
@@ -212,7 +212,7 @@ namespace SqlSugar
{
if (this.Context.IsSystemTablesConfig)
{
return this.Context.DbMaintenance.GetIsIdentities(this.EntityInfo.DbTableName);
return this.Context.DbMaintenance.GetIsIdentities(this.Context.EntityProvider.GetTableName(this.EntityInfo.EntityName));
}
else
{