public SqlOrderingRepositories(SqlDbSession session) { mContactRepository = new SqlContactRepository(session); mVendorRepository = new SqlVendorRepository(session); mProductBrandRepository = new SqlProductBrandRepository(session); mProductCategoryRepository = new SqlProductCategoryRepository(session); mProductSubCategoryRepository = new SqlProductSubCategoryRepository(session); mProductRepository = new SqlProductRepository(session); mVendorProductRepository = new SqlVendorProductRepository(session); mPurOrderRepository = new SqlPurOrderRepository(session); mPurLineRepository = new SqlPurLineRepository(session, mProductCategoryRepository); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += new ThreadExceptionEventHandler(ExceptionHandler); Ambient.Configure(new StaticAmbientDataProvider()); SqlDbSession session = new SqlDbSession("OrderingDev"); Ambient.DbSession = session; OrderingRepositories.Configure(new SqlOrderingRepositories(session)); Application.Run(new MDIMain()); }
public static IServiceCollection AddKnstArchitectureMultiSql(this IServiceCollection services) { var types = AppDomain.CurrentDomain .GetAssemblies() .SelectMany(a => a.DefinedTypes .Where(x => x .GetInterfaces() .Contains(typeof(IRepo)) && !x.IsInterface && !x.IsAbstract)) .ToList(); foreach (var type in types) { if (typeof(SqlRepo).IsAssignableFrom(type)) { continue; } services.TryAdd(new ServiceDescriptor(type, type, ServiceLifetime.Transient)); var interfaces = type.GetInterfaces().ToList(); foreach (var @interface in interfaces) { services.TryAdd(new ServiceDescriptor(@interface, sp => sp.GetRequiredService(type), ServiceLifetime.Transient)); } } services.TryAddKnstArchitectureDbSessionBag(); services.TryAddKnstArchitectureLazy(); services.AddTransient <IMultiSqlDbSession, MultiSqlDbSession>(); services.AddScoped <IMultiSqlUnitOfWork, MultiSqlUnitOfWork>(); services.AddTransient <ISqlRepoFactory, SqlRepoFactory>(); services.AddTransient <RichSqlDbSession>(sp => { var result = new RichSqlDbSession(); var dbSessionBag = sp.GetRequiredService <IDbSessionBag>(); var connections = sp.GetServices <IDbConnection>().ToList(); foreach (var connection in connections) { var session = new SqlDbSession(dbSessionBag, connection); result.Add(session); } return(result); }); return(services); }
public SqlProductBrandRepository(SqlDbSession session) : base(session) { }
public SqlVendorProductRepository(SqlDbSession session) : base(session) { }
public SqlPurLineRepository(SqlDbSession session, SqlProductCategoryRepository categoryRep) : base(session) { mCategoryRep = categoryRep; }
public SqlProductSubCategoryRepository(SqlDbSession session) : base(session) { }
public SqlContactRepository(SqlDbSession session) : base(session) { }
public SqlPurOrderRepository(SqlDbSession session) : base(session) { }