ScopedServices is an inherited property from OwningComponentBase that exposes an IServiceProvider for services created in a component-specific dependency-injection scope. That scope follows the component lifecycle and is not shared with other components. section 36.3.1
Use it when a component needs isolated scoped services:
- Inherit from OwningComponentBase. section 36.3.1
- Obtain each service requiring the dedicated scope through ScopedServices; services injected with Inject remain in the request scope. section 36.3.1
- Use OwningComponentBase<T> when one typed scoped service is sufficient; access it through Service. section 36.3.1
Obtaining a component-owned DataContext
A component can inherit OwningComponentBase and retrieve DataContext through ScopedServices: DataContext? Context => ScopedServices.GetService<DataContext>();. The typed alternative inherits OwningComponentBase<DataContext> and assigns Context => Service. section 36.3.1
