4747 string _defaultConstructorArgument = null;
4848 string DefaultConstructorArgument {get {return _defaultConstructorArgument ?? String.Format('"' + "Name={0}" + '"',ConnectionStringName);} set {_defaultConstructorArgument = value;}}
4949 string ConfigurationClassName = "Configuration";
50+ string CollectionInterfaceType = "System.Collections.Generic.ICollection";
5051 string CollectionType = "System.Collections.Generic.List";
5152 static bool NullableShortHand = true;
5253 bool UseDataAnnotations = false;
639640 }
640641
641642 // Work out if there are any foreign key relationship naming clashes
642- reader.ProcessForeignKeys(fkList, tables, UsePascalCase, PrependSchemaName, CollectionType, true, IncludeComments, ForeignKeyName, UseDataAnnotationsSchema, ForeignKeyProcessing, ForeignKeyAnnotationsProcessing);
643+ reader.ProcessForeignKeys(fkList, tables, UsePascalCase, PrependSchemaName, CollectionType, CollectionInterfaceType, true, IncludeComments, ForeignKeyName, UseDataAnnotationsSchema, ForeignKeyProcessing, ForeignKeyAnnotationsProcessing);
643644 if(UseMappingTables)
644- tables.IdentifyMappingTables(fkList, UsePascalCase, CollectionType, true, IncludeComments, IsSqlCe, ForeignKeyName, ForeignKeyAnnotationsProcessing);
645+ tables.IdentifyMappingTables(fkList, UsePascalCase, CollectionInterfaceType, CollectionType, true, IncludeComments, IsSqlCe, ForeignKeyName, ForeignKeyAnnotationsProcessing);
645646
646647 // Now we know our foreign key relationships and have worked out if there are any name clashes,
647648 // re-map again with intelligently named relationships.
648649 tables.ResetNavigationProperties();
649650
650- reader.ProcessForeignKeys(fkList, tables, UsePascalCase, PrependSchemaName, CollectionType, false, IncludeComments, ForeignKeyName, UseDataAnnotationsSchema, ForeignKeyProcessing, ForeignKeyAnnotationsProcessing);
651+ reader.ProcessForeignKeys(fkList, tables, UsePascalCase, PrependSchemaName, CollectionInterfaceType, CollectionType, false, IncludeComments, ForeignKeyName, UseDataAnnotationsSchema, ForeignKeyProcessing, ForeignKeyAnnotationsProcessing);
651652 if(UseMappingTables)
652- tables.IdentifyMappingTables(fkList, UsePascalCase, CollectionType, false, IncludeComments, IsSqlCe, ForeignKeyName, ForeignKeyAnnotationsProcessing);
653+ tables.IdentifyMappingTables(fkList, UsePascalCase, CollectionInterfaceType, CollectionType, false, IncludeComments, IsSqlCe, ForeignKeyName, ForeignKeyAnnotationsProcessing);
653654
654655 conn.Close();
655656 return tables;
15011502 public abstract Tables ReadSchema(Regex schemaFilterExclude, Regex schemaFilterInclude, Regex tableFilterExclude, Regex tableFilterInclude, Regex columnFilterExclude, Func<Table, bool> tableFilter, bool usePascalCase, bool prependSchemaName, CommentsStyle includeComments, bool includeViews, CommentsStyle includeExtendedPropertyComments, Func<string, string, bool, string> tableRename, Func<Column, Table, Column> updateColumn, bool usePrivateSetterForComputedColumns, bool includeSynonyms, bool dataAnnotations, bool dataAnnotationsSchema, bool isSqlCe, Dictionary<string, string> columnNameToDataAnnotation, bool includeConnectionSettingComments);
15021503 public abstract List<StoredProcedure> ReadStoredProcs(Regex SchemaFilterExclude, Regex storedProcedureFilterExclude, bool usePascalCase, bool prependSchemaName , Func<StoredProcedure, string> StoredProcedureRename, bool includeTableValuedFunctions, bool includeConnectionSettingComments);
15031504 public abstract List<ForeignKey> ReadForeignKeys(Func<string, string, bool, string> tableRename, Func<ForeignKey, ForeignKey> foreignKeyFilter);
1504- public abstract void ProcessForeignKeys(List<ForeignKey> fkList, Tables tables, bool usePascalCase, bool prependSchemaName, string collectionType, bool checkForFkNameClashes, CommentsStyle includeComments, Func<string, ForeignKey, string, Relationship, short, string> ForeignKeyName, bool dataAnnotationsSchema, Func<IList<ForeignKey>, Table, Table, bool, ForeignKey> foreignKeyProcessing, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing);
1505+ public abstract void ProcessForeignKeys(List<ForeignKey> fkList, Tables tables, bool usePascalCase, bool prependSchemaName, string collectionInterfaceType, string collectionType, bool checkForFkNameClashes, CommentsStyle includeComments, Func<string, ForeignKey, string, Relationship, short, string> ForeignKeyName, bool dataAnnotationsSchema, Func<IList<ForeignKey>, Table, Table, bool, ForeignKey> foreignKeyProcessing, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing);
15051506 public abstract void IdentifyForeignKeys(List<ForeignKey> fkList, Tables tables);
15061507 public abstract void ReadIndexes(Tables tables);
15071508 public abstract void ReadExtendedProperties(Tables tables, bool includeConnectionSettingComments);
@@ -2609,7 +2610,7 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
26092610 }
26102611 }
26112612
2612- public override void ProcessForeignKeys(List<ForeignKey> fkList, Tables tables, bool usePascalCase, bool prependSchemaName, string collectionType, bool checkForFkNameClashes, CommentsStyle includeComments, Func<string, ForeignKey, string, Relationship, short, string> ForeignKeyName, bool dataAnnotationsSchema, Func<IList<ForeignKey>, Table, Table, bool, ForeignKey> foreignKeyProcessing, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing)
2613+ public override void ProcessForeignKeys(List<ForeignKey> fkList, Tables tables, bool usePascalCase, bool prependSchemaName, string collectionInterfaceType, string collectionType, bool checkForFkNameClashes, CommentsStyle includeComments, Func<string, ForeignKey, string, Relationship, short, string> ForeignKeyName, bool dataAnnotationsSchema, Func<IList<ForeignKey>, Table, Table, bool, ForeignKey> foreignKeyProcessing, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing)
26132614 {
26142615 var constraints = fkList.Select(x => x.FkSchema + "." + x.ConstraintName).Distinct();
26152616 foreach (var constraint in constraints)
@@ -2694,7 +2695,7 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
26942695 }
26952696
26962697 if(foreignKey.IncludeReverseNavigation)
2697- pkTable.AddReverseNavigation(relationship, pkTableHumanCase, fkTable, fkPropName, string.Format("{0}.{1}", fkTable.Name, foreignKey.ConstraintName), collectionType, includeComments, foreignKeys, foreignKeyAnnotationsProcessing);
2698+ pkTable.AddReverseNavigation(relationship, pkTableHumanCase, fkTable, fkPropName, string.Format("{0}.{1}", fkTable.Name, foreignKey.ConstraintName), collectionInterfaceType, collectionType, includeComments, foreignKeys, foreignKeyAnnotationsProcessing);
26982699 }
26992700 }
27002701
@@ -3320,7 +3321,7 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
33203321 return ForeignKeyName(tableNameHumanCase, foreignKey, fkName, relationship, 6);
33213322 }
33223323
3323- public void AddReverseNavigation(Relationship relationship, string fkName, Table fkTable, string propName, string constraint, string collectionType, CommentsStyle includeComments, List<ForeignKey> fks, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing = null, Table mappingTable = null)
3324+ public void AddReverseNavigation(Relationship relationship, string fkName, Table fkTable, string propName, string constraint, string collectionInterfaceType, string collectionType, CommentsStyle includeComments, List<ForeignKey> fks, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing = null, Table mappingTable = null)
33243325 {
33253326 string fkNames = "";
33263327 switch (relationship)
@@ -3368,7 +3369,7 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
33683369 new PropertyAndComments()
33693370 {
33703371 AdditionalDataAnnotations = foreignKeyAnnotationsProcessing(fkTable, this, propName),
3371- Definition = string.Format("public {0}System.Collections.Generic.ICollection< {1}> {2 } {{ get; set; }}{3}{4 }", GetLazyLoadingMarker(), fkTable.NameHumanCaseWithSuffix, propName, initialization1, includeComments != CommentsStyle.None ? " // " + constraint : string.Empty),
3372+ Definition = string.Format("public {0}{1}<{2} > {3 } {{ get; set; }}{4}{5 }", GetLazyLoadingMarker(), collectionInterfaceType , fkTable.NameHumanCaseWithSuffix, propName, initialization1, includeComments != CommentsStyle.None ? " // " + constraint : string.Empty),
33723373 Comments = string.Format("Child {0} where [{1}].{2} point to this entity ({3})", Inflector.MakePlural(fkTable.NameHumanCase), fkTable.Name, fkNames, fks.First().ConstraintName)
33733374 }
33743375 );
@@ -3383,7 +3384,7 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
33833384 new PropertyAndComments()
33843385 {
33853386 AdditionalDataAnnotations = foreignKeyAnnotationsProcessing(fkTable, this, propName),
3386- Definition = string.Format("public {0}System.Collections.Generic.ICollection< {1}> {2 } {{ get; set; }}{3}{4 }", GetLazyLoadingMarker(), fkTable.NameHumanCaseWithSuffix, propName, initialization2, includeComments != CommentsStyle.None ? " // Many to many mapping" : string.Empty),
3387+ Definition = string.Format("public {0}{1}<{2} > {3 } {{ get; set; }}{4}{5 }", GetLazyLoadingMarker(), collectionInterfaceType , fkTable.NameHumanCaseWithSuffix, propName, initialization2, includeComments != CommentsStyle.None ? " // Many to many mapping" : string.Empty),
33873388 Comments = string.Format("Child {0} (Many-to-Many) mapped by table [{1}]", Inflector.MakePlural(fkTable.NameHumanCase), mappingTable == null ? string.Empty : mappingTable.Name)
33883389 }
33893390 );
@@ -3406,7 +3407,7 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
34063407 }});", leftPropName, rightPropName, left.FkTableName, left.FkColumn, right.FkColumn, isSqlCe ? string.Empty : ", \"" + left.FkSchema + "\""));
34073408 }
34083409
3409- public void IdentifyMappingTable(List<ForeignKey> fkList, Tables tables, bool usePascalCase, string collectionType, bool checkForFkNameClashes, CommentsStyle includeComments, bool isSqlCe, Func<string, ForeignKey, string, Relationship, short, string> foreignKeyName, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing)
3410+ public void IdentifyMappingTable(List<ForeignKey> fkList, Tables tables, bool usePascalCase, string collectionInterfaceType, string collectionType, bool checkForFkNameClashes, CommentsStyle includeComments, bool isSqlCe, Func<string, ForeignKey, string, Relationship, short, string> foreignKeyName, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing)
34103411 {
34113412 IsMapping = false;
34123413
@@ -3452,8 +3453,8 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
34523453 leftTable.AddMappingConfiguration(left, right, usePascalCase, leftPropName, rightPropName, isSqlCe);
34533454
34543455 IsMapping = true;
3455- rightTable.AddReverseNavigation(Relationship.ManyToMany, rightTable.NameHumanCase, leftTable, rightPropName, null, collectionType, includeComments, null, foreignKeyAnnotationsProcessing, this);
3456- leftTable.AddReverseNavigation(Relationship.ManyToMany, leftTable.NameHumanCase, rightTable, leftPropName, null, collectionType, includeComments, null, foreignKeyAnnotationsProcessing, this);
3456+ rightTable.AddReverseNavigation(Relationship.ManyToMany, rightTable.NameHumanCase, leftTable, rightPropName, null, collectionInterfaceType, collectionType, includeComments, null, foreignKeyAnnotationsProcessing, this);
3457+ leftTable.AddReverseNavigation(Relationship.ManyToMany, leftTable.NameHumanCase, rightTable, leftPropName, null, collectionInterfaceType, collectionType, includeComments, null, foreignKeyAnnotationsProcessing, this);
34573458 }
34583459
34593460 public void SetupDataAnnotations()
@@ -3485,11 +3486,11 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
34853486 }
34863487 }
34873488
3488- public void IdentifyMappingTables(List<ForeignKey> fkList, bool usePascalCase, string collectionType, bool checkForFkNameClashes, CommentsStyle includeComments, bool isSqlCe, Func<string, ForeignKey, string, Relationship, short, string> foreignKeyName, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing)
3489+ public void IdentifyMappingTables(List<ForeignKey> fkList, bool usePascalCase, string collectionInterfaceType, string collectionType, bool checkForFkNameClashes, CommentsStyle includeComments, bool isSqlCe, Func<string, ForeignKey, string, Relationship, short, string> foreignKeyName, Func<Table, Table, string, string[]> foreignKeyAnnotationsProcessing)
34893490 {
34903491 foreach(var tbl in this.Where(x => x.HasForeignKey))
34913492 {
3492- tbl.IdentifyMappingTable(fkList, this, usePascalCase, collectionType, checkForFkNameClashes, includeComments, isSqlCe, foreignKeyName, foreignKeyAnnotationsProcessing);
3493+ tbl.IdentifyMappingTable(fkList, this, usePascalCase, collectionInterfaceType, collectionType, checkForFkNameClashes, includeComments, isSqlCe, foreignKeyName, foreignKeyAnnotationsProcessing);
34933494 }
34943495 }
34953496
0 commit comments