-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDbmsEnvironment.cs
More file actions
74 lines (65 loc) · 2.69 KB
/
DbmsEnvironment.cs
File metadata and controls
74 lines (65 loc) · 2.69 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Linq;
using System.Collections.Generic;
using T4SQL.MetaData;
namespace T4SQL
{
public class DbmsEnvironment
{
private readonly Func<string, IEnumerable<DbmsColumn>> _fListTableColumns;
private readonly Func<string, DbmsRelationTree> _fLoadForeignKeys;
private readonly string _DatabasePlatform;
private readonly string _DatabaseProduct;
private readonly Version _ProductVersion;
private readonly string _ServerName;
public string DatabasePlatform { get { return _DatabasePlatform; } }
public string DatabaseProduct { get { return _DatabaseProduct; } }
public Version ProductVersion { get { return _ProductVersion; } }
public string ServerName { get { return _ServerName; } }
// internal Func<string, IEnumerable<DbmsColumn>> FuncListTableColumns { get { return _fListTableColumns; } }
// internal Func<string, DbmsRelationTree> FuncLoadForeignKeys { get { return _fLoadForeignKeys; } }
public DbmsEnvironment(Func<string, IEnumerable<DbmsColumn>> fListTableColumns,
Func<string, DbmsRelationTree> fLoadForeignKeys,
string databasePlatform, string databaseProduct, string productVersion, string serverName)
{
_fListTableColumns = fListTableColumns;
_fLoadForeignKeys = fLoadForeignKeys;
_DatabasePlatform = databasePlatform;
_DatabaseProduct = databaseProduct;
_ProductVersion = new Version(productVersion);
_ServerName = serverName;
}
public IEnumerable<string> ListTableColumns(string tableName, string specificColumns = "*")
{
if (string.IsNullOrWhiteSpace(specificColumns) || specificColumns.Trim() == "*")
return _fListTableColumns(tableName).Select(col => col.ColumnName);
else
return specificColumns.SplitColumns();
}
public JoinedTable NavigateForeignKeyTable(string foreignKeyBaseTable)
{
DbmsRelationTree baseTable = _fLoadForeignKeys(foreignKeyBaseTable);
return new JoinedTable(baseTable);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2013 Abel Cheng
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
// See http://www.apache.org/licenses/LICENSE-2.0.
// All other rights reserved.
// You must not remove this notice, or any other, from this software.
//
// Original Author: Abel Cheng <abelcys@gmail.com>
// Created Date: May 14, 2013, 12:00:23 AM
// Primary Host: http://t4sql.codeplex.com
// Change Log:
// Author Date Comment
//
//
//
//
// (Keep code clean rather than complicated code plus long comments.)
//
////////////////////////////////////////////////////////////////////////////////////////////////////