Quantcast
Channel: patterns & practices: Project Silk
Viewing all articles
Browse latest Browse all 93

New Post: How to create DbContext for long running process?

$
0
0

Hi,

As far as I know, using construction injection will result in a small overhead compared to creating an instance manually, as the container needs to analyze the class through reflexion, resolve the dependencies, etc. However, this overhead only affects the construction of the object; the performance of the code in the object should not be affected.

If this overhead is significant or not will depend mostly each application. For most applications, it's not an issue as the performance loss experienced when using constructor injection is minimal compared to the benefits obtained. However, if your application requires to have a very high performance, using dependency injection might not be an useful approach.

As a side note, based on my understanding, it's not recommended to use the DbContext directly. Usually, the recommended approach is to implement a kind of service which would wrap the DbContext and manage it. Then, the application interacts with the service to consume data instead of interacting directly with the DbContext. For example, in MileageStats, the application interacts with the data through the implementation of repositories.

I hope you find this useful,

Damian Cherubini
http://blogs.southworks.net/dcherubini


Viewing all articles
Browse latest Browse all 93

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>