DI中Transient Scoped Singleton Instance的区别
Observe which of the OperationId
values varies within a request, and between requests.
Transient
objects are always different; a new instance is provided to every controller and every service.Scoped
objects are the same within a request, but different across different requestsSingleton
objects are the same for every object and every request (regardless of whether an instance is provided inConfigureServices
)