Coder Social home page Coder Social logo

Comments (11)

Ratankalwa avatar Ratankalwa commented on May 24, 2024 1

from threenine.data.

garywoodfine avatar garywoodfine commented on May 24, 2024

Unfortunately at this moment in time, we have not implemented functionality to enable your requirement at present.

We do have the Dependency Injection at this moment to add multiple Db Contexts, but we have not implemented functionality within the repository layer to enable switching between them as of yet.

On our own projects we now try not to use this approach at all, primarily because we have preferred to use Microservice approach this solve this, so we have Microservices with their own databases and contexts to facilitate.

s

from threenine.data.

Ratankalwa avatar Ratankalwa commented on May 24, 2024

from threenine.data.

garywoodfine avatar garywoodfine commented on May 24, 2024

Sure no worries I will sort that out now

from threenine.data.

cjabbour avatar cjabbour commented on May 24, 2024

I was able to inject 2 units of work into the same service using the IUnitOfWork<ExampleContextA> and IUnitOfWork<ExampleContextB> and they both worked fine.

from threenine.data.

Ratankalwa avatar Ratankalwa commented on May 24, 2024

from threenine.data.

cjabbour avatar cjabbour commented on May 24, 2024

Hi Ratan

For now, I'm not changing any connectionstrings on the fly. During startup, I'm initializing my 2 DbContexts with something like this:
services.AddDbContext<CoreDbContext>(options => options.UseSqlServer(coreConnString)).AddUnitOfWork<CoreDbContext>();
services.AddDbContext<AuxDbContext>(options => options.UseSqlServer(auxConnString)).AddUnitOfWork<AuxDbContext>();

and then in a query handler in my data layer - separate from my biz layer - I'm injecting the UOW like this
private readonly IUnitOfWork<CoreDbContext> _coreUnitOfWork;
private readonly IUnitOfWork<AuxContext> _auxUnitOfWork;

I haven't noticed any issues with those UOWs yet - however, I'm still in kind of a proof-of-concept stage with this project.

I hope this helps. Would love to hear some feedback if you end up trying it.

@garywoodfine is there anything that seems wrong to you with this approach?

from threenine.data.

Ratankalwa avatar Ratankalwa commented on May 24, 2024

from threenine.data.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.