/// <summary> /// The drop and create read database. /// </summary> public bool DropAndCreateReadDatabase() { try { System.Data.Entity.Database.SetInitializer(new ReadInitializer()); var readContext = new ReadContext(); readContext.Database.Initialize(true); return true; } catch (Exception ex) { this.logger.Error(ex); Debug.WriteLine(ex.Message); return false; } }
/// <summary> /// The create registrations in db. /// </summary> public static void CreateRegistrationsInDb() { var context = new ReadContext(); context.RegistrationTypes.AddOrUpdate(r => r.Id, SampleRegistrationTypes.CreateRegistrationTypeBook()); context.RegistrationTypes.AddOrUpdate(r => r.Id, SampleRegistrationTypes.CreateRegistrationTypeMovie()); context.PropertyTypes.AddOrUpdate(p => p.Id, SamplePropertyTypes.CreatePropertyTypeAuthor()); context.PropertyTypes.AddOrUpdate(p => p.Id, SamplePropertyTypes.CreatePropertyTypePublished()); context.Properties.AddOrUpdate(r => r.Id, SampleProperties.CreatePropertyHarariDb()); context.Properties.AddOrUpdate(r => r.Id, SampleProperties.CreateProperty2014Db()); context.Properties.AddOrUpdate(r => r.Id, SampleProperties.CreatePropertyKubrickDb()); context.Properties.AddOrUpdate(r => r.Id, SampleProperties.CreateProperty1968Db()); var sapiensProperties = new Collection<Property> { context.Properties.Find(1), context.Properties.Find(2) }; var properties2001 = new Collection<Property> { context.Properties.Find(3), context.Properties.Find(4) }; context.Registrations.AddOrUpdate(r => r.Id, SampleRegistrations.CreateRegistrationSapiensDb(sapiensProperties)); context.Registrations.AddOrUpdate(r => r.Id, SampleRegistrations.CreateRegistration2001Db(properties2001)); context.SaveChanges(); }
/// <summary> /// The create registration repository. /// </summary> public static Repository<Registration> CreateRegistrationRepository() { var readContext = new ReadContext(); return new Repository<Registration>(readContext); }
/// <summary> /// The create property type repository. /// </summary> public static Repository<PropertyType> CreatePropertyTypeRepository() { var readContext = new ReadContext(); return new Repository<PropertyType>(readContext); }