Update db.First razor

This commit is contained in:
sunkaixuan
2022-04-08 11:58:00 +08:00
parent 3f9d2a48bd
commit 857f3da246
2 changed files with 8 additions and 1 deletions

View File

@@ -144,6 +144,7 @@ namespace SqlSugar
Check.Exception(true, ErrorMessage.GetThrowMessage("Need to achieve ConnectionConfig.ConfigureExternal Services.RazorService", "需要实现 ConnectionConfig.ConfigureExternal Services.RazorService接口"));
}
this.Context.Utilities.RemoveCacheAll();
result.FormatFileNameFunc = this.FormatFileNameFunc;
return result;
}
#endregion

View File

@@ -10,6 +10,7 @@ namespace SqlSugar
public class RazorFirst
{
internal List<KeyValuePair<string,string>> ClassStringList { get; set; }
internal Func<string, string> FormatFileNameFunc { get; set; }
public static string DefaultRazorClassTemplate =
@"using System;
@@ -79,7 +80,12 @@ namespace @Model.Namespace
{
foreach (var item in ClassStringList)
{
var filePath = directoryPath.TrimEnd('\\').TrimEnd('/') + string.Format(seChar + "{0}.cs", item.Key);
var fileName = item.Key;
if (this.FormatFileNameFunc != null)
{
fileName = this.FormatFileNameFunc(fileName);
}
var filePath = directoryPath.TrimEnd('\\').TrimEnd('/') + string.Format(seChar + "{0}.cs",fileName);
FileHelper.CreateFile(filePath, item.Value, Encoding.UTF8);
}
}