|
1 | 1 | using System.Collections.Generic; |
2 | 2 | using System.Data.Entity.Core.Metadata.Edm; |
3 | 3 | using System.Linq; |
| 4 | +using SQLite.CodeFirst.Builder.NameCreators; |
4 | 5 | using SQLite.CodeFirst.Statement; |
5 | 6 | using SQLite.CodeFirst.Utility; |
6 | 7 |
|
@@ -31,14 +32,27 @@ private IEnumerable<CreateTableStatement> GetCreateTableStatements() |
31 | 32 | ICollection<AssociationType> associationTypes = |
32 | 33 | edmModel.AssociationTypes.Where(a => a.Constraint.ToRole.Name == entitySet.Name).ToList(); |
33 | 34 |
|
34 | | - var b = associationTypes.Select(a => new AssociationTypeWrapper |
| 35 | + IList<AssociationTypeWrapper> associationTypeWrappers = new List<AssociationTypeWrapper>(); |
| 36 | + foreach (var associationType in associationTypes) |
35 | 37 | { |
36 | | - AssociationType = a, |
37 | | - FromTableName = edmModel.Container.GetEntitySetByName(a.Constraint.FromRole.Name, true).Table, |
38 | | - ToTableName = edmModel.Container.GetEntitySetByName(a.Constraint.ToRole.Name, true).Table |
39 | | - }); |
| 38 | + string fromSchema = edmModel.Container.GetEntitySetByName(associationType.Constraint.FromRole.Name, true).Schema; |
| 39 | + string fromName = edmModel.Container.GetEntitySetByName(associationType.Constraint.FromRole.Name, true).Table; |
40 | 40 |
|
41 | | - var tableStatementBuilder = new CreateTableStatementBuilder(entitySet, b); |
| 41 | + string toSchema = edmModel.Container.GetEntitySetByName(associationType.Constraint.ToRole.Name, true).Schema; |
| 42 | + string toName = edmModel.Container.GetEntitySetByName(associationType.Constraint.ToRole.Name, true).Table; |
| 43 | + |
| 44 | + string fromTableName = TableNameCreator.CreateTableName(fromSchema, fromName); |
| 45 | + string toTableName = TableNameCreator.CreateTableName(toSchema, toName); |
| 46 | + |
| 47 | + associationTypeWrappers.Add(new AssociationTypeWrapper |
| 48 | + { |
| 49 | + AssociationType = associationType, |
| 50 | + FromTableName = fromTableName, |
| 51 | + ToTableName = toTableName |
| 52 | + }); |
| 53 | + } |
| 54 | + |
| 55 | + var tableStatementBuilder = new CreateTableStatementBuilder(entitySet, associationTypeWrappers); |
42 | 56 | yield return tableStatementBuilder.BuildStatement(); |
43 | 57 | } |
44 | 58 | } |
|
0 commit comments