Is there any easy way to avoid open and close connection when using code like this :
using (Entities context = new Entities())
{
returnValue = context.ExecuteStoreCommand(sqlStr, param1, param2, param3, param4, param5, param6, param7);
context.SaveChanges();
return returnValue;
}
I have alot of code like this in diffrent methods that need to be runned in a massive database(MySQL update. It would go much faster if it did not open/close connection between each method (using/SaveChanges).
Maby I have to change the code entirely and place the context as a static member and then remove the using from all the methods? Or is there a easy setting?