Update split table default length

This commit is contained in:
sunkaixuan 2024-02-03 13:56:53 +08:00
parent e375a73cbd
commit f5f72c1631
2 changed files with 7 additions and 3 deletions

View File

@ -30,6 +30,7 @@ namespace SqlSugar
{ {
var result = new SplitCodeFirstProvider(); var result = new SplitCodeFirstProvider();
result.Context = this.Context; result.Context = this.Context;
result.DefaultLength = this.DefultLength;
return result; return result;
} }

View File

@ -10,6 +10,9 @@ namespace SqlSugar
public class SplitCodeFirstProvider public class SplitCodeFirstProvider
{ {
public SqlSugarProvider Context; public SqlSugarProvider Context;
public int DefaultLength { get; set; }
public void InitTables<T>() public void InitTables<T>()
{ {
var type = typeof(T); var type = typeof(T);
@ -27,7 +30,7 @@ namespace SqlSugar
} }
else else
{ {
this.Context.CodeFirst.InitTables(type); this.Context.CodeFirst.SetStringDefaultLength(this.DefaultLength).InitTables(type);
} }
} }
@ -46,13 +49,13 @@ namespace SqlSugar
foreach (var item in tables) foreach (var item in tables)
{ {
this.Context.MappingTables.Add(helper.EntityInfo.EntityName, item.TableName); this.Context.MappingTables.Add(helper.EntityInfo.EntityName, item.TableName);
this.Context.CodeFirst.InitTables(type); this.Context.CodeFirst.SetStringDefaultLength(this.DefaultLength).InitTables(type);
} }
} }
else else
{ {
this.Context.MappingTables.Add(helper.EntityInfo.EntityName, helper.GetDefaultTableName()); this.Context.MappingTables.Add(helper.EntityInfo.EntityName, helper.GetDefaultTableName());
this.Context.CodeFirst.InitTables(type); this.Context.CodeFirst.SetStringDefaultLength(this.DefaultLength).InitTables(type);
} }
this.Context.MappingTables.Add(helper.EntityInfo.EntityName, helper.EntityInfo.DbTableName); this.Context.MappingTables.Add(helper.EntityInfo.EntityName, helper.EntityInfo.DbTableName);
} }