Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which scope should i use for binding DbContext with Ninject in WPF App

In a web project i would use the RequestScope when binding the DbContext to my real DB context. But in WPF should i go for singleton or transcient scope ? Does it really matter which one over the other i choose ?

like image 799
Rushino Avatar asked Dec 06 '25 16:12

Rushino


1 Answers

Depending on the complexity of your app I would start with PerThreadScope. That way you have one for the apps main thread and for each background thread. They are tracked by ninject and properly disposed. If your app gets complexer you can switch to NamedScope or InCallScope and thereby scope the db context per RootView.

like image 139
Daniel Marbach Avatar answered Dec 08 '25 08:12

Daniel Marbach



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!