public void Persistence_1_and_2() { BuilderSetup builderSetup = new BuilderSetup(); // Not identical, but enough to know they're ok var productRepository = new ProductRepository(); builderSetup.SetCreatePersistenceMethod <Model.Product>(productRepository.Create); builderSetup.SetCreatePersistenceMethod <IList <Model.Product> >(productRepository.CreateAll); new Builder <Product>(builderSetup).CreateNew().Persist(); }
public void ShouldBeAbleToSetCreatePersistenceMethod() { Action <MyClass> func = x => repository.Save(x); using (mocks.Record()) { persistenceService.Expect(x => x.SetPersistenceCreateMethod(func)); } builderSetup.SetCreatePersistenceMethod <MyClass>(func); }
public BuilderSetup DoSetup() { BuilderSetup builderSetup = new BuilderSetup(); EnsureActiveRecordInitialized(); if (setup) { return(builderSetup); } setup = true; var productRepository = Dependency.Resolve <IProductRepository>(); var taxTypeRepository = Dependency.Resolve <ITaxTypeRepository>(); var categoryRepository = Dependency.Resolve <ICategoryRepository>(); builderSetup.SetCreatePersistenceMethod <Product>(productRepository.Create); builderSetup.SetCreatePersistenceMethod <IList <Product> >(productRepository.CreateAll); builderSetup.SetCreatePersistenceMethod <TaxType>(taxTypeRepository.Create); builderSetup.SetCreatePersistenceMethod <IList <TaxType> >(taxTypeRepository.CreateAll); builderSetup.SetCreatePersistenceMethod <Category>(categoryRepository.Create); builderSetup.SetCreatePersistenceMethod <IList <Category> >(categoryRepository.CreateAll); builderSetup.SetUpdatePersistenceMethod <Category>(categoryRepository.Save); builderSetup.SetUpdatePersistenceMethod <IList <Category> >(categoryRepository.SaveAll); return(builderSetup); }
private static Guid CreateChurch() { var churchRepository = NativeInjectionDependency.GetInstance <IChurchRepository>(); var unitOfWork = NativeInjectionDependency.GetInstance <IUnitOfWork>(); BuilderSetup.SetCreatePersistenceMethod <Church>(churchRepository.Add); var church = Builder <Church> .CreateNew() .With(x => x.HomePhone, Telephone.Factory.CreateNew(21, "55555555")) .With(x => x.CellPhone, Telephone.Factory.CreateNew(21, "987413333")) .With(x => x.Email, Email.Factory.CreateNew($"scorponok{Guid.NewGuid()}@gmail.com")) .Persist(); unitOfWork.Commit(); return(church.Id); }
public override void Up() { Delete.FromTable("Tasks").AllRows(); BuilderSetup.DisablePropertyNamingFor <Task, int?>(x => x.Id); BuilderSetup.SetCreatePersistenceMethod <IList <Task> >(tasks => tasks.ToList().ForEach(task => Insert.IntoTable("Tasks").Row(new { // NOTE: Add in columns with int conversion Name = task.Name, //IsCompleted = task.IsCompleted, Priority = (int)task.Priority, Status = (int)task.Status, }))); Builder <Task> .CreateListOfSize(5) .Persist(); }
public BuilderSetup DoSetup() { BuilderSetup builderSetup = new BuilderSetup(); EnsureActiveRecordInitialized(); if (setup) return builderSetup; setup = true; var productRepository = Dependency.Resolve<IProductRepository>(); var taxTypeRepository = Dependency.Resolve<ITaxTypeRepository>(); var categoryRepository = Dependency.Resolve<ICategoryRepository>(); builderSetup.SetCreatePersistenceMethod<Product>(productRepository.Create); builderSetup.SetCreatePersistenceMethod<IList<Product>>(productRepository.CreateAll); builderSetup.SetCreatePersistenceMethod<TaxType>(taxTypeRepository.Create); builderSetup.SetCreatePersistenceMethod<IList<TaxType>>(taxTypeRepository.CreateAll); builderSetup.SetCreatePersistenceMethod<Category>(categoryRepository.Create); builderSetup.SetCreatePersistenceMethod<IList<Category>>(categoryRepository.CreateAll); builderSetup.SetUpdatePersistenceMethod<Category>(categoryRepository.Save); builderSetup.SetUpdatePersistenceMethod<IList<Category>>(categoryRepository.SaveAll); return builderSetup; }