1+ using QuantumConcepts . CodeGenerator . Core . Utils ;
2+ using QuantumConcepts . Common . Extensions ;
13using System ;
24using System . Collections . Generic ;
3- using System . Text ;
4- using System . Xml . Serialization ;
5- using QuantumConcepts . CodeGenerator . Core . Utils ;
65using System . IO ;
7- using System . Xml ;
8- using System . Xml . XPath ;
96using System . Linq ;
10- using QuantumConcepts . Common . Extensions ;
7+ using System . Xml ;
118using System . Xml . Linq ;
12- using QuantumConcepts . Common . Utils ;
13- using QuantumConcepts . CodeGenerator . Core . Upgrade ;
9+ using System . Xml . Serialization ;
1410
1511namespace QuantumConcepts . CodeGenerator . Core . ProjectSchema
1612{
@@ -122,6 +118,8 @@ public XDocument GetXDocument(out XmlNamespaceManager nsm)
122118
123119 private void Initialize ( )
124120 {
121+ EnsureConnectionsExist ( ) ;
122+
125123 this . UserSettings . JoinToProject ( this ) ;
126124 this . Connections . ForEach ( o => o . JoinToParent ( this ) ) ;
127125 this . DataTypeMappings . ForEach ( o => o . JoinToProject ( this ) ) ;
@@ -131,6 +129,25 @@ private void Initialize()
131129 this . ForeignKeyMappings . ForEach ( o => o . JoinToProject ( this ) ) ;
132130 }
133131
132+ private void EnsureConnectionsExist ( )
133+ {
134+ var connectionNames = this . Connections . Select ( o => o . Name ) . Union ( this . UserSettings . Connections . Select ( o => o . Name ) ) . Distinct ( ) . ToList ( ) ;
135+
136+ this . Connections . AddRange ( ( from name in connectionNames
137+ where ! this . Connections . Any ( o => string . Equals ( o . Name , name ) )
138+ select new ConnectionInfo
139+ {
140+ Name = name
141+ } ) ) ;
142+
143+ this . UserSettings . Connections . AddRange ( ( from name in connectionNames
144+ where ! this . UserSettings . Connections . Any ( o => string . Equals ( o . Name , name ) )
145+ select new Connection
146+ {
147+ Name = name
148+ } ) ) ;
149+ }
150+
134151 public DataTypeMapping FindDataTypeMapping ( string databaseDataType )
135152 {
136153 return this . DataTypeMappings . SingleOrDefault ( o => o . DatabaseDataType . EqualsIgnoreCase ( databaseDataType ) ) ;
@@ -140,7 +157,7 @@ public TableMapping FindTableMapping(string connectionName, string schemaName, s
140157 {
141158 return this . TableMappings . SingleOrDefault ( o =>
142159 o . ConnectionName . EqualsIgnoreCase ( connectionName )
143- && o . SchemaName . EqualsIgnoreCase ( schemaName )
160+ && o . SchemaName . EqualsIgnoreCase ( schemaName )
144161 && o . TableName . EqualsIgnoreCase ( name ) ) ;
145162 }
146163
@@ -151,9 +168,9 @@ public Template FindTemplate(string xsltAbsolutePath)
151168
152169 public ViewMapping FindViewMapping ( string connectionName , string schemaName , string name )
153170 {
154- return this . ViewMappings . SingleOrDefault ( o =>
171+ return this . ViewMappings . SingleOrDefault ( o =>
155172 o . ConnectionName . EqualsIgnoreCase ( connectionName )
156- && o . SchemaName . EqualsIgnoreCase ( schemaName )
173+ && o . SchemaName . EqualsIgnoreCase ( schemaName )
157174 && o . TableName . EqualsIgnoreCase ( name ) ) ;
158175 }
159176
0 commit comments