Skip to content

Commit ced9fbb

Browse files
2881028810
authored andcommitted
- 优化 FreeSql.Generator -Match 支持生成一个表;
1 parent ede456f commit ced9fbb

File tree

2 files changed

+176
-190
lines changed

2 files changed

+176
-190
lines changed

Extensions/FreeSql.Generator/ConsoleApp.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using RazorEngine.Templating;
1+
using FreeSql.DatabaseModel;
2+
using RazorEngine.Templating;
23
using System;
4+
using System.Collections.Generic;
35
using System.Drawing;
46
using System.IO;
57
using System.Linq;
@@ -111,7 +113,7 @@ public ConsoleApp(string[] args, ManualResetEvent wait)
111113
默认生成:表+视图+存储过程
112114
如果不想生成视图和存储过程 -Filter View+StoreProcedure
113115
114-
-Match 正则表达式,只生成匹配的表,如:dbo\.TB_.+
116+
-Match 表名或正则表达式,只生成匹配的表,如:dbo\.TB_.+
115117
116118
-FileName 文件名,默认:{name}.cs
117119
-Output 保存路径,默认为当前 shell 所在目录
@@ -219,7 +221,18 @@ public ConsoleApp(string[] args, ManualResetEvent wait)
219221
.UseMonitorCommand(cmd => Console.WriteFormatted(cmd.CommandText + "\r\n", Color.SlateGray))
220222
.Build())
221223
{
222-
var tables = fsql.DbFirst.GetTablesByDatabase();
224+
List<DbTableInfo> tables = new List<DbTableInfo>();
225+
if (string.IsNullOrEmpty(ArgsMatch) == false)
226+
{
227+
try
228+
{
229+
var matchTable = fsql.DbFirst.GetTableByName(ArgsMatch);
230+
if (matchTable != null) tables.Add(matchTable);
231+
}
232+
catch { }
233+
}
234+
if (tables.Any() == false)
235+
tables = fsql.DbFirst.GetTablesByDatabase();
223236
var outputTables = tables;
224237

225238
//开始生成操作

0 commit comments

Comments
 (0)