-
Notifications
You must be signed in to change notification settings - Fork 1
/
ListSqlType.cs
37 lines (32 loc) · 890 Bytes
/
ListSqlType.cs
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
using Dapper;
using System;
using System.Collections.Generic;
using System.Text;
namespace Albatross.Database.SqlServer
{
public class ListSqlType : IListSqlType {
IGetDbConnection getDbConnection;
public ListSqlType(IGetDbConnection getDbConnection) {
this.getDbConnection = getDbConnection;
}
public IEnumerable<SqlType> List(Database database) {
using (var db = getDbConnection.Get(database)) {
return db.Query<SqlType>(GetCommand());
}
}
CommandDefinition GetCommand() {
return new CommandDefinition(@"
select
schemas.name as [Schema],
types.Name,
types.max_length as MaxLength,
types.Precision,
types.Scale,
types.is_nullable as IsNullable,
types.is_user_defined as IsUserDefined,
types.is_table_type as IsTableType
from sys.types join sys.schemas on types.schema_id = schemas.schema_id
");
}
}
}