forked from dotnetcore/SmartCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDbTableSource.cs
More file actions
52 lines (49 loc) · 1.73 KB
/
Copy pathDbTableSource.cs
File metadata and controls
52 lines (49 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using Microsoft.Extensions.Logging;
using SmartCode.Configuration;
using SmartCode.Db;
using SmartCode.Generator.Entity;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SmartCode.Generator
{
public class DbTableSource : DbSource, ITableSource
{
public DbTableSource(
Project project
, ILoggerFactory loggerFactory
, IPluginManager pluginManager
) : base(project, loggerFactory, pluginManager)
{
}
public override string Name => "DbTable";
public IList<Table> Tables { get; private set; }
public override async Task InitData()
{
var dbTableRepository = new DbTableRepository(Project.DataSource, LoggerFactory);
DbRepository = dbTableRepository;
Tables = await dbTableRepository.QueryTable();
var dbTypeConvert = PluginManager.Resolve<IDbTypeConverter>();
foreach (var table in Tables)
{
foreach (var col in table.Columns)
{
if ((DbRepository.DbProvider == Db.DbProvider.MySql ||
DbRepository.DbProvider == Db.DbProvider.MariaDB)
&& col.DbType == "char"
&& col.DataLength == 36
&& Project.Language == "CSharp")
{
col.LanguageType = "Guid";
}
else
{
col.LanguageType =
dbTypeConvert.LanguageType(DbRepository.DbProvider, Project.Language, col.DbType);
}
}
}
}
}
}