Quantcast
Channel: URF - Unit of Work & (extensible/generic) Repositories Framework
Viewing all articles
Browse latest Browse all 1539

New Post: Multiple Entity Framework Contexts(Multiple database types) on the same time.

$
0
0
Hi,

Depending on your front end ContainerControlledLifetimeManager is still creates a singleton instance so just take AGBrown's advice above on Lifetime management.

When declaring your Service make sure that you add an Injection Dependency attribute to the constructor arguments so that the correct unit of work is passed in.

i.e.
public class MyService : Service<DB1ContextRepository>, IMyService
{
    public MyServiceDB1(
        IRepositoryAsync<DB1ContextRepository> dB1ContextRepository,
        [Dependency("DB1Context")] IUnitOfWorkAsync unitOfWork)
    {
        if (dB1ContextRepository == null) { throw new ArgumentNullException("dB1ContextRepository"); }
        if (unitOfWork == null) { throw new ArgumentNullException("unitOfWork"); }
        
        this.dB1ContextRepository = dB1ContextRepository;
        this.unitOfWork = unitOfWork;
    }
Regards

Toby.

Viewing all articles
Browse latest Browse all 1539

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>