Hi,
Is there a way to access the database from within the user control?
I donβt think there is anything stopping you from doing that. You can request any dependencies from DI by adding them as a constructor parameter.
However, Iβd advice against it and suggest placing the data fetching logic into the ViewModel of the control, if it a markup control. Nested view models can also inherit DotvvmViewModelBase and override the Init, Load, PreRender methods.
1 Like