Resolving IoC dependencies in data layer / arbitrary classes

I’m missing something basic here. I cannot figure how to resolve to IoC elements inside a function where the class isn’t a service or a request object?

Let’s say in the DataLayer, a class needs access to the db so it needs a reference to IDbConnection.

Is the general idea to create a globally accessible singleton which can resolve to the IDbConnection and return it?

Basically, how does an arbitrary class resolve a reference to an IoC dependency?

Sounds like you want to use the built-in RepositoryBase class, here’s an answer explaining its usage.

Otherwise this answer shows how to resolve an IOC dependency from anywhere.

HostContext and ServiceStackHost is exactly what I was looking for. Thanks!!