-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSqlTypes.cs
More file actions
41 lines (34 loc) · 988 Bytes
/
SqlTypes.cs
File metadata and controls
41 lines (34 loc) · 988 Bytes
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
using FizzCode.DbTools.Common;
namespace FizzCode.DbTools.DataDefinition.Base;
public class SqlTypes : SqlEngineVersionDictionary<SqlType>
{
public void SetAllNullable(bool isNullable)
{
foreach (var sqlType in Values)
{
sqlType.IsNullable = isNullable;
}
}
private SqlEngineVersion GetVersion()
{
if (Keys.Any(k => SqlEngineVersions.GetAllVersions<GenericVersion>().Contains(k)))
{
return SqlEngineVersions.GetLatestVersionOfDialect<GenericVersion>();
}
return Keys.Last();
}
public string Describe(SqlEngineVersion? preferredVersion = null)
{
var version = preferredVersion;
version ??= GetVersion();
return this[version].ToString();
}
public SqlTypes CopyTo(SqlTypes sqlTypes)
{
foreach (var kvp in this)
{
sqlTypes.Add(kvp.Key, (SqlType)kvp.Value.Copy());
}
return sqlTypes;
}
}