mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-25 04:27:14 +08:00
DbFirst support format file name
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user