Пример #1
0
 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);
 }
Пример #2
0
        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);
        }
Пример #4
0
 public SqlProductBrandRepository(SqlDbSession session)
     : base(session)
 {
 }
 public SqlVendorProductRepository(SqlDbSession session)
     : base(session)
 {
 }
Пример #6
0
 public SqlPurLineRepository(SqlDbSession session, SqlProductCategoryRepository categoryRep)
     : base(session)
 {
     mCategoryRep = categoryRep;
 }
Пример #7
0
 public SqlProductSubCategoryRepository(SqlDbSession session)
     : base(session)
 {
 }
Пример #8
0
 public SqlContactRepository(SqlDbSession session)
     : base(session)
 {
 }
Пример #9
0
 public SqlPurOrderRepository(SqlDbSession session)
     : base(session)
 {
 }