Skip to content

Commit 60ee7fb

Browse files
authored
Merge pull request #16473 from hvitved/csharp/entity-framework-perf
C#: Fix performance issue in EntityFramework modelling
2 parents 1a20a62 + d9019f9 commit 60ee7fb

File tree

2 files changed

+100
-185
lines changed

2 files changed

+100
-185
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/EntityFramework.qll

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,26 +437,21 @@ module EntityFramework {
437437
) {
438438
this = dbSet.getDbContextClass() and
439439
this.output(output, mapped, dbSet) and
440-
result = dbSet.getFullName() + "#" + output.getMadRepresentation()
440+
exists(string qualifier, string type, string name |
441+
mapped.hasFullyQualifiedName(qualifier, type, name) and
442+
result = getQualifiedName(qualifier, type, name)
443+
)
441444
}
445+
446+
pragma[nomagic]
447+
string getSyntheticNameProj(Property mapped) { result = this.getSyntheticName(_, mapped, _) }
442448
}
443449

444450
private class DbContextClassSetProperty extends Property {
445451
private DbContextClass c;
446452

447453
DbContextClassSetProperty() { this = c.getADbSetProperty(_) }
448454

449-
/**
450-
* Gets the fully qualified name for this.
451-
*/
452-
string getFullName() {
453-
exists(string qualifier, string type, string name |
454-
this.hasFullyQualifiedName(qualifier, type, name)
455-
|
456-
result = getQualifiedName(qualifier, type, name)
457-
)
458-
}
459-
460455
/**
461456
* Gets the context class where this is a DbSet property.
462457
*/
@@ -493,7 +488,7 @@ module EntityFramework {
493488
exists(string name, Property mapped |
494489
preservesValue = true and
495490
c.input(input, mapped) and
496-
name = c.getSyntheticName(_, mapped, _) and
491+
name = c.getSyntheticNameProj(mapped) and
497492
output = SummaryComponentStack::syntheticGlobal(name) and
498493
model = "DbContextSaveChanges"
499494
)
@@ -504,7 +499,7 @@ module EntityFramework {
504499
* Add all possible synthetic global names.
505500
*/
506501
private class EFSummarizedCallableSyntheticGlobal extends SummaryComponent::SyntheticGlobal {
507-
EFSummarizedCallableSyntheticGlobal() { this = any(DbContextClass c).getSyntheticName(_, _, _) }
502+
EFSummarizedCallableSyntheticGlobal() { this = any(DbContextClass c).getSyntheticNameProj(_) }
508503
}
509504

510505
private class DbContextSaveChangesRequiredSummaryComponentStack extends RequiredSummaryComponentStack

0 commit comments

Comments
 (0)