usually people wrap the operation as follows:
using (context = new )
{
Get;
SaveChanges
}
sometimes there is another layer with transaction
I don't think Microsoft is stupid enough to open a new connection per operation; it must be cached.
But what you were suggesting is open the connection manually before I perform any operation, close it after the last one. I truly don't think that's necessary. However, I tried it anyway. According to the performance profile, it seems to be 1 second slower on average, I will respectfully say your suggestion doesn't make any difference.
Please let me know if I misinterpret your idea.
One option is to use compiled queries, but there is no (custom) query in our cases, mainly are SaveChanges and TryGetObjectByKey.
We still feel the headache, any other hints? thanks
using (context = new )
{
Get;
SaveChanges
}
sometimes there is another layer with transaction
I don't think Microsoft is stupid enough to open a new connection per operation; it must be cached.
But what you were suggesting is open the connection manually before I perform any operation, close it after the last one. I truly don't think that's necessary. However, I tried it anyway. According to the performance profile, it seems to be 1 second slower on average, I will respectfully say your suggestion doesn't make any difference.
Please let me know if I misinterpret your idea.
One option is to use compiled queries, but there is no (custom) query in our cases, mainly are SaveChanges and TryGetObjectByKey.
We still feel the headache, any other hints? thanks