File tree Expand file tree Collapse file tree 3 files changed +31
-6
lines changed
Expand file tree Collapse file tree 3 files changed +31
-6
lines changed Original file line number Diff line number Diff line change 22<#@ include file="SqlServer.ttinclude" #>
33<#
44 Settings.Host = Host;
5- Context = new SqlGeneratorContext(Settings.Connection);
5+ using(Context = new SqlGeneratorContext(Settings.Connection))
6+ {
67#>
78using Microsoft.Extensions.DependencyInjection;
89using SubSonic;
@@ -28,5 +29,21 @@ namespace TemplateIntegrationTest.DAL
2829#>
2930 public ISubSonicSetCollection<Models.<#=table.Name#>> <#=table.Name.Pluralize()#> { get; protected set; }
3031<#}#>
32+ protected override void OnDbModeling(DbModelBuilder builder)
33+ {
34+ if (builder == null)
35+ {
36+ throw new ArgumentNullException(nameof(builder));
37+ }
38+ <#foreach(Models.Table table in Context.Tables) {
39+ if (Settings.ExcludeTables.Any(x => x.Equals(table.Name, StringComparison.OrdinalIgnoreCase)))
40+ {
41+ continue;
42+ }
43+ #>
44+ builder.AddEntityModel<Models.<#=table.Name#>>();
45+ <#}#>
46+ }
3147 }
32- }
48+ }
49+ <#}#>
Original file line number Diff line number Diff line change 3333 <packages repository =" extension" repositoryId =" SubSonic.Core.VisualStudio.d0e28cfc-1997-48b5-bff3-b1c24fc847ba" >
3434 <package id =" Microsoft.Extensions.DependencyInjection.Abstractions" version =" 3.1.7" />
3535 <package id =" Microsoft.Extensions.Logging.Abstractions" version =" 3.1.7" />
36- <package id =" SubSonic.Core.DAL" version =" 4.3.0-alpha.6 " />
37- <package id =" SubSonic.Extensions.SqlServer" version =" 4.2 .1" />
36+ <package id =" SubSonic.Core.DAL" version =" 4.3.0-alpha.13 " />
37+ <package id =" SubSonic.Extensions.SqlServer" version =" 4.3.0-alpha .1" />
3838 </packages >
3939 </WizardData >
4040</VSTemplate >
Original file line number Diff line number Diff line change 33<#@ import namespace="System.Linq" #>
44<#
55 Settings.Host = Host;
6- Context = new SqlGeneratorContext(Settings.Connection);
6+ using (Context = new SqlGeneratorContext(Settings.Connection))
7+ {
78#>using System;
89using System.ComponentModel.DataAnnotations;
910using System.ComponentModel.DataAnnotations.Schema;
11+ using SubSonic;
1012
1113namespace TemplateIntegrationTest.DAL.Models
1214{
@@ -17,6 +19,11 @@ namespace TemplateIntegrationTest.DAL.Models
1719 }
1820#>
1921 [Table("<#=table.Name#>", Schema = "<#=table.Schema#>")]
22+ <#if (Context.TableTypes.Any(x => x.SchemaOwner == table.Schema && x.Name == table.Name)) {
23+ Models.TableType tableType = Context.TableTypes.Single(x => x.SchemaOwner == table.Schema && x.Name == table.Name);
24+ #>
25+ [DbUserDefinedTableType("<#=tableType.Name#>", SchemaName = "<#=tableType.SchemaOwner#>")]
26+ <#}#>
2027 public partial class <#=table.Name#>
2128 {
2229 public <#=table.Name#>() { }
@@ -54,4 +61,5 @@ namespace TemplateIntegrationTest.DAL.Models
5461 }
5562
5663<#}#>
57- }
64+ }
65+ <#}#>
You can’t perform that action at this time.
0 commit comments