-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
50 lines (45 loc) · 1.55 KB
/
Program.cs
File metadata and controls
50 lines (45 loc) · 1.55 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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using static DSQLDM.Models;
namespace DSQLDM
{
class Models
{
public class Schema
{
public string Name { get; set; }
}
public class Table
{
public string Name { get; set; }
public Schema Schema { get; set; }
}
public class Column
{
public string Name { get; set; }
public int OrdinalPosition { get; set; }
public string DataType { get; set; }
public int CharMaxLength { get; set; }
public Table ClTable { get; set; }
}
}
class Program
{
static async Task Main(string[] args)
{
Column p = await new DB<Column>("Server=DEX\\SQLEXPRESS;Database=master;Trusted_Connection=True")
.QuerySingle(@"SELECT TABLE_SCHEMA AS [ClTable.Schema.Name],
TABLE_NAME AS [ClTable.Name],
COLUMN_NAME AS [Name],
ORDINAL_POSITION AS [OrdinalPosition],
DATA_TYPE AS [DataType],
CHARACTER_MAXIMUM_LENGTH AS [CharMaxLength] FROM INFORMATION_SCHEMA.COLUMNS", new { });
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(p));
/*
{"Name":"xserver_name","OrdinalPosition":1,"DataType":"varchar","CharMaxLength":30,"ClTable":{"Name":"spt_fallback_db","Schema":{"Name":"dbo"}}}
*/
}
}
}