开发者

Is there any alternative that does not close a connection to ExecuteStoreCommand

We are talking for one ObjectContext per Request concept. (Web Application) WE dont close connection between Application_BeginRequest and Application_EndRequest. We have a single ObjectContext during the Request. We open it and dont close during the Request.

There is a ExecuteStoreCommand in Entity Fra开发者_如何学运维mework but this is a little dangerous for performance. Because when we use it (I think) it closes a connection. And when we use ObjectContext after it connection is opened again (this is performance problem?)

So is there any alternative to ExecuteStoreCommand or am I crazy :)


"Closing" and "Opening" connection doesn't have any real performance impact if you correctly use connection pooling. The connection pool holds several opened connections which are reused by multiple subsequent actions. Open in most cases only means "get me a connection from the pool" and close means "return the connection to the pool". The connection pool will handle opening a new connection if none is available in the pool as well as limit number of concurrently used connections. Connection pool is defined per connection string + user identity.

ExceuteStoreCommand closes connection only if no connection was opened when the command started execution. It means that if you use your own connection passed to the context it will not close it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜