c# - Use namespace to distinguish between two IUnitOfWork implementation -
I'm developing C #, .NET Framework 4.0 with an ASP.NET MVC 4 mesh API, the unit code code first 6.0 and Nunzek
I would like to have two separate This is my custom Both If I have two different Maybe I can use the same You should name them Allows you to do this: DbContext custom assignments because I have to connect to two separate databases.
DbContext class implementation
public class EFDbContext:. DbContext, IUnitOfWork {public EFDbContext (): base ("name = EFDbContext") {// Exit, then there is no database, do not create database.SetInitializer & LT; EFDbContext & gt; (Zero); } Protected Override Zero OnModelCreating (DbModelBuilder modelBuilder) {modelBuilder.Configurations.Add (new CONFIGURATIONSConfiguration ()); Modlbilder Configuration. Add (new code configuration ()); Modlbilder Configuration. Add (new AGGREGATION_CHILDS configuration ()); Modlbilder Configuration. Add (new AGGREGATIONSConfiguration ()); Base.OnModelCreating (modelBuilder); }}
DbContext custom classes
IUnitOfWork and my problem is that if I get from them how do I distinguish between them Do not know how to do
NinjectConfigurator class:
Private Zero AddBindings (IKernel Container) {ConfigureLog4net (Container); Container.Bind & LT; IUnitOfWork & gt; () & Lt; EFDbContext & gt; () InRequestScope (); // hidden implementation ...}
EFDbContext classes, how can I distinguish them from
NinjectConfigurator
IUnitOfWork interface with two different namespaces and I can use the namespace to differentiate between them. The problem here is that I will repeat the same interface in two different names spaces.
bind & Lt; IUnitOfWork & gt; () & Lt ;. EFDbContext & gt; () Name ("ef"); Bind & lt; IUnitOfWork & gt; () & Lt; OtherDbContext & gt; () Name ("other");
class MyRepository {Personal IUnitOfWork _unitOfWork; Public ([Named ("EF")] IUnitOfWork unitOfWork) _unitOfWork = unitOfWork; }}
Comments
Post a Comment