@@ -124,7 +124,8 @@ public override ForeignKeyConstraint[] GetForeignKeyConstraints(string tableName
124124 }
125125
126126 var createTableScript = GetSqlCreateTableScript ( tableName ) ;
127- var regEx = ForeignKeyRegex ( ) ;
127+ // GeneratedRegex
128+ var regEx = new Regex ( @"CONSTRAINT\s+\w+\s+FOREIGN\s+KEY\s*\([^)]+\)\s+REFERENCES\s+\w+\s*\([^)]+\)" ) ;
128129 var matchesCollection = regEx . Matches ( createTableScript ) ;
129130 var fkParts = matchesCollection . Cast < Match > ( ) . ToList ( ) . Where ( x => x . Success ) . Select ( x => x . Value ) . ToList ( ) ;
130131
@@ -137,7 +138,7 @@ public override ForeignKeyConstraint[] GetForeignKeyConstraints(string tableName
137138
138139 foreach ( var fkPart in fkParts )
139140 {
140- var regexParenthesis = ForeignKeyParenthesisRegex ( ) ;
141+ var regexParenthesis = new Regex ( @"\(([^)]+)\)" ) ;
141142 var parenthesisContents = regexParenthesis . Matches ( fkPart ) . Cast < Match > ( ) . Select ( x => x . Groups [ 1 ] . Value ) . ToList ( ) ;
142143
143144 if ( parenthesisContents . Count != 2 )
@@ -147,11 +148,11 @@ public override ForeignKeyConstraint[] GetForeignKeyConstraints(string tableName
147148
148149 var foreignKeyExtract = new ForeignKeyExtract ( )
149150 {
150- ChildColumnNames = parenthesisContents [ 0 ] . Split ( "," ) . Select ( x => x . Trim ( ) ) . ToList ( ) ,
151- ParentColumnNames = parenthesisContents [ 1 ] . Split ( "," ) . Select ( x => x . Trim ( ) ) . ToList ( ) ,
151+ ChildColumnNames = parenthesisContents [ 0 ] . Split ( ',' ) . Select ( x => x . Trim ( ) ) . ToList ( ) ,
152+ ParentColumnNames = parenthesisContents [ 1 ] . Split ( ',' ) . Select ( x => x . Trim ( ) ) . ToList ( ) ,
152153 } ;
153154
154- var foreignKeyConstraintNameRegex = ForeignKeyConstraintNameRegex ( ) ;
155+ var foreignKeyConstraintNameRegex = new Regex ( @"CONSTRAINT\s+(\w+)\s+FOREIGN\s+KEY" ) ;
155156 var foreignKeyNameMatch = foreignKeyConstraintNameRegex . Match ( fkPart ) ;
156157
157158 if ( ! foreignKeyNameMatch . Success )
@@ -1297,12 +1298,5 @@ protected override void ConfigureParameterWithValue(IDbDataParameter parameter,
12971298 base . ConfigureParameterWithValue ( parameter , index , value ) ;
12981299 }
12991300 }
1300-
1301- [ GeneratedRegex ( @"CONSTRAINT\s+\w+\s+FOREIGN\s+KEY\s*\([^)]+\)\s+REFERENCES\s+\w+\s*\([^)]+\)" ) ]
1302- private static partial Regex ForeignKeyRegex ( ) ;
1303- [ GeneratedRegex ( @"\(([^)]+)\)" ) ]
1304- private static partial Regex ForeignKeyParenthesisRegex ( ) ;
1305- [ GeneratedRegex ( @"CONSTRAINT\s+(\w+)\s+FOREIGN\s+KEY" ) ]
1306- private static partial Regex ForeignKeyConstraintNameRegex ( ) ;
13071301 }
13081302}
0 commit comments