Skip to content

Commit 6f4df3f

Browse files
committed
added a view class wrapper for getting a list of table types
1 parent 28064cd commit 6f4df3f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

SubSonic.Core.DataAccessLayer/src/CodeGenerator/GeneratorContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ protected GeneratorContext(string connection, LogLevel logLevel)
2121
public ISubSonicSetCollection<Models.Table> Tables { get; protected set; }
2222
public ISubSonicSetCollection<Models.Column> Columns { get; protected set; }
2323
public ISubSonicSetCollection<Models.Relationship> Relationships { get; protected set; }
24+
public ISubSonicSetCollection<Models.TableType> TableTypes { get; protected set; }
2425

2526
protected override void OnDbConfiguring(DbContextOptionsBuilder builder)
2627
{
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using SubSonic.Attributes;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace SubSonic.CodeGenerator.Models
7+
{
8+
[DbView(Query = SqlQuery)]
9+
public class TableType
10+
{
11+
public const string SqlQuery = @"select
12+
[Id] = CAST(tt.type_table_object_id as bigint),
13+
[SchemaOwner] = s.[name],
14+
[Name] = tt.[name]
15+
from sys.table_types tt
16+
join sys.schemas s on s.schema_id = tt.schema_id
17+
where tt.is_table_type = 1
18+
";
19+
20+
public long Id { get; set; }
21+
public string SchemaOwner { get; set; }
22+
public string Name { get; set; }
23+
}
24+
}

0 commit comments

Comments
 (0)