55// Created: 2009.11.07
66
77using System . Collections . Generic ;
8+ using System . Collections . ObjectModel ;
9+ using JetBrains . Annotations ;
10+ using Xtensive . Core ;
811
912namespace Xtensive . Sql . Compiler
1013{
@@ -13,20 +16,39 @@ namespace Xtensive.Sql.Compiler
1316 /// </summary>
1417 public sealed class SqlPostCompilerConfiguration
1518 {
16- public HashSet < object > AlternativeBranches { get ; private set ; }
19+ public HashSet < object > AlternativeBranches { get ; private set ; } = new HashSet < object > ( ) ;
1720
18- public Dictionary < object , string > PlaceholderValues { get ; private set ; }
21+ public Dictionary < object , string > PlaceholderValues { get ; private set ; } = new Dictionary < object , string > ( ) ;
1922
20- public Dictionary < object , List < string [ ] > > DynamicFilterValues { get ; private set ; }
23+ public Dictionary < object , List < string [ ] > > DynamicFilterValues { get ; private set ; } = new Dictionary < object , List < string [ ] > > ( ) ;
24+
25+ /// <summary>
26+ /// Gets database mapping.
27+ /// </summary>
28+ public IReadOnlyDictionary < string , string > SchemaMapping { get ; private set ; }
29+
30+ /// <summary>
31+ /// Gets database mapping.
32+ /// </summary>
33+ public IReadOnlyDictionary < string , string > DatabaseMapping { get ; private set ; }
2134
2235
2336 // Constructors
2437
2538 public SqlPostCompilerConfiguration ( )
2639 {
27- AlternativeBranches = new HashSet < object > ( ) ;
28- PlaceholderValues = new Dictionary < object , string > ( ) ;
29- DynamicFilterValues = new Dictionary < object , List < string [ ] > > ( ) ;
40+ // this prevents wrong query to be executed.
41+ SchemaMapping = null ;
42+ DatabaseMapping = null ;
43+ }
44+
45+ public SqlPostCompilerConfiguration ( [ NotNull ] IReadOnlyDictionary < string , string > databaseMapping , [ NotNull ] IReadOnlyDictionary < string , string > schemaMapping )
46+ {
47+ ArgumentValidator . EnsureArgumentNotNull ( databaseMapping , "databaseMapping" ) ;
48+ ArgumentValidator . EnsureArgumentNotNull ( schemaMapping , "schemaMapping" ) ;
49+
50+ DatabaseMapping = databaseMapping ;
51+ SchemaMapping = schemaMapping ;
3052 }
3153 }
3254}
0 commit comments