Exemple #1
0
        /// <summary>
        /// Задать зависимости проекта .Data.
        /// </summary>
        /// <param name="kernel">Ядро IoC.</param>
        private static void ConfigureDataServices(IKernel kernel)
        {
            FluentMappingConfiguration.ConfigureMapping();
            kernel.Bind <IUnitOfWorkFactory>().To <UnitOfWorkFactory>().InTransientScope();

            kernel.Bind <IUserRepository>().To <UserRepository>().InTransientScope();
            kernel.Bind <IPlanRepository>().To <PlanRepository>().InTransientScope();
            kernel.Bind <IEducationalWorkTypeRepository>().To <EducationalWorkTypeRepository>().InTransientScope();
            kernel.Bind <IEducationalWorkRepository>().To <EducationalWorkRepository>().InTransientScope();
        }
Exemple #2
0
        public void Test()
        {
            try
            {
                IServiceCollection serviceCollection = new ServiceCollection();
                FluentMappingConfiguration.ConfigureMapping();

                IConfigurationRoot configuration = GetConfiguration();
                using (UnitOfWork unitOfWork = new UnitOfWork(configuration))
                {
                    unitOfWork.BeginTransaction();
                    UserBase user = new UserBase()
                    {
                        Login        = "******",
                        Name         = "--",
                        Surname      = "login",
                        CreatedOn    = DateTime.Now,
                        PasswordHash = SecurePasswordHasher.Hash("password")
                    };
                    user.Id = unitOfWork.UserRepository.Insert(user);

                    var list = unitOfWork.UserRepository.Query(new UserFilter()
                    {
                        Login = "******"
                    });

                    unitOfWork.RollbackTransaction();

                    //            unitOfWork.BeginTransaction();
                    //            List<_TestEntityBase> list = unitOfWork._TestEntityRepository.GetAllBase();
                    //_TestEntityBase first = list.First();
                    //            first.Name = "Updated name 3";
                    //            unitOfWork._TestEntityRepository.Update(first);
                    //            unitOfWork.RollbackTransaction();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 /// <summary>
 /// Задать зависимости проекта .Data.
 /// </summary>
 /// <param name="services">Набор сервисов.</param>
 private static void ConfigureDataServices(IServiceCollection services)
 {
     FluentMappingConfiguration.ConfigureMapping();
     services.AddTransient <IUnitOfWorkFactory, UnitOfWorkFactory>();
 }
 /// <summary>
 /// Задать зависимости проекта .Data.
 /// </summary>
 /// <param name="kernel">Ядро IoC.</param>
 private static void ConfigureDataServices(IKernel kernel)
 {
     FluentMappingConfiguration.ConfigureMapping();
     kernel.Bind <IUnitOfWorkFactory>().To <UnitOfWorkFactory>().InTransientScope();
 }
 static BaseTest()
 {
     FluentMappingConfiguration.ConfigureMapping();
 }