ErikEJ / EntityFramework6PowerTools

This is the codebase for Entity Framework 6 Power Tools Community Edition, and modern EF 6 providers for SQL Server and SQL Server Compact
Other
183 stars 27 forks source link

Generate Pre-compiled View Using switch Statement #55

Closed khodaie closed 5 years ago

khodaie commented 5 years ago

The generated view pattern is based on the if statement:

if (extentName == "EntityModelsStoreContainer.Supplier")
{
         return GetView0();
}

if (extentName == "EntityModelsStoreContainer.Product")
{
         return GetView1();
}
...

But the switch statement has better performance when the number of conditions is high. So, using switch instead of if can improve the overall performance:

switch(extentName )
{
  case "EntityModelsStoreContainer.Supplier": return GetView0();
  case "EntityModelsStoreContainer.Product": return GetView0();
...
}
ErikEJ commented 5 years ago

This project is open source and acccpts Pull Requests