'ASP.NET and Spring - Singleton or Scoped/Prototype
Im really confused, Daily I work with java and spring and in Spring-community it is almost obvious that Repositorium/DAO and Services are Singletons (which is default scope for Java component). It's even recommended by Spring Docs. Of course it is possible to change scope but it is not recommended.
Now I have to learn ASP.NET basics and in ASP.NET default scope for repository/dao is "Scoped" which means component is recreated every new request and DAO/Repository Singletons are Anti-Patterns.
What is right way to create Data Access components or Services? Is it Framework dependent or maybe it is because in ASP.NET using async/await Tasks with repository/data context methods?
What's difference in performence on both ways? What's right way?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|