DbFirst support format file name

This commit is contained in:
sunkaixuan
2022-04-08 11:34:59 +08:00
parent fbfa1da769
commit c6c8cb5f5f
2 changed files with 13 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ namespace SqlSugar
private bool IsAttribute { get; set; }
private bool IsDefaultValue { get; set; }
private Func<string, bool> WhereColumnsfunc;
private Func<string, string> FormatFileNameFunc { get; set; }
private ISqlBuilder SqlBuilder
{
get
@@ -147,6 +148,11 @@ namespace SqlSugar
this.IsAttribute = isCreateAttribute;
return this;
}
public IDbFirst FormatFileName(Func<string, string> formatFileNameFunc)
{
this.FormatFileNameFunc = formatFileNameFunc;
return this;
}
public IDbFirst IsCreateDefaultValue(bool isCreateDefaultValue = true)
{
this.IsDefaultValue = isCreateDefaultValue;
@@ -319,7 +325,12 @@ namespace SqlSugar
{
foreach (var item in classStringList)
{
var filePath = directoryPath.TrimEnd('\\').TrimEnd('/') + string.Format(seChar + "{0}.cs", item.Key);
var fileName = item.Key;
if (FormatFileNameFunc!= null)
{
fileName = FormatFileNameFunc(fileName);
}
var filePath = directoryPath.TrimEnd('\\').TrimEnd('/') + string.Format(seChar + "{0}.cs", fileName);
FileHelper.CreateFile(filePath, item.Value, Encoding.UTF8);
}
}

View File

@@ -23,5 +23,6 @@ namespace SqlSugar
void CreateClassFile(string directoryPath, string nameSpace = "Models");
Dictionary<string, string> ToClassStringList(string nameSpace = "Models");
void Init();
IDbFirst FormatFileName(Func<string,string> formatFileNameFunc);
}
}