Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
/ t4models Public archive

Commit

Permalink
fixies
Browse files Browse the repository at this point in the history
  • Loading branch information
ili committed Nov 19, 2017
1 parent 7aad7dc commit 250ce56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Templates/DataModel.ttinclude
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,12 @@ void LoadMetadata(DataConnection dataConnection)

foreach (var t in Tables.Values)
{
var forbidden = KeyWords.Concat(new [] {t.TypeName});

var hasDuplicates = t.Columns.Values
.Select(c => c.MemberName)
.Concat(t.ForeignKeys.Values.Select(f => f.MemberName))
.Concat(forbidden)
.ToLookup(n => n)
.Any(g => g.Count() > 1);

Expand All @@ -467,6 +470,7 @@ void LoadMetadata(DataConnection dataConnection)
{
var mayDuplicate = t.Columns.Values
.Select(c => c.MemberName)
.Concat(forbidden)
.Concat(t.ForeignKeys.Values.Where(f => f != fk).Select(f => f.MemberName));

fk.MemberName = SuggestNoDuplicate(mayDuplicate, fk.MemberName, "FK");
Expand All @@ -477,6 +481,7 @@ void LoadMetadata(DataConnection dataConnection)
var mayDuplicate = t.Columns.Values
.Where(c => c != col)
.Select(c => c.MemberName)
.Concat(forbidden)
.Concat(t.ForeignKeys.Values.Select(fk => fk.MemberName));

col.MemberName = SuggestNoDuplicate(mayDuplicate, col.MemberName, null);
Expand Down
2 changes: 1 addition & 1 deletion Tests/LinqToDB/SqlServer.tt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<#@ include file="..\..\Templates\ObsoleteAttributes.ttinclude" #>
<#@ include file="SqlServer.ttinclude" #>
<#@ assembly name="$(SolutionDir)\packages\Microsoft.SqlServer.Types.14.0.314.76\lib\net40\Microsoft.SqlServer.Types.dll" #>
<#@ assembly name="$(SolutionDir)\packages\linq2db.1.8.3\lib\net40\linq2db.dll" #>
<#@ assembly name="$(SolutionDir)\packages\linq2db.1.10.0\lib\net40\linq2db.dll" #>
<#
// NamespaceName = "DataContext";
// DataContextName = "NorthwindDB";
Expand Down

0 comments on commit 250ce56

Please sign in to comment.