private static void runEfContext() { Database.SetInitializer(new DropCreateDatabaseIfModelChanges <CookbookMfContext>()); using (var context = new CookbookMfContext()) { seed(context); } }
public DefaultEfRepository(CookbookMfContext context) { if (context == null) { throw new ArgumentNullException("context"); } m_context = context; }
private static void seed(CookbookMfContext context) { const string dummyRecipeText = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae felis sapien. Sed a faucibus lacus."; var standardCategory = new RecipeCategory("Všední jídla"); var specilitiesCategory = new RecipeCategory("Specialitky"); context.RecipeCategories.Add(standardCategory); context.RecipeCategories.Add(specilitiesCategory); context.Recipes.Add(new Recipe { Category = standardCategory, Name = "Michaná vajíčka", Description = dummyRecipeText }); context.Recipes.Add(new Recipe { Category = standardCategory, Name = "Párky", Description = dummyRecipeText }); context.Recipes.Add(new Recipe { Category = specilitiesCategory, Name = "Lahůdkové párky", Description = dummyRecipeText }); context.Recipes.Add(new Recipe { Category = specilitiesCategory, Name = "Babicova pizza", Description = dummyRecipeText }); context.Recipes.Add(new Recipe { Category = specilitiesCategory, Name = "Kuře Vindaloo", Description = dummyRecipeText }); context.SaveChanges(); }
private static void initServices() { //Polovičaté mapování abstrakce na implementaci var context = new CookbookMfContext(); SimpleServiceRepository.Instance.RegisterService <IRepository <Recipe> >(new DefaultEfRepository <Recipe>(context)); SimpleServiceRepository.Instance.RegisterService <IRepository <RecipeCategory> >( new DefaultEfRepository <RecipeCategory>(context)); SimpleServiceRepository.Instance.RegisterService <IExporter>(new WordExporter()); SimpleServiceRepository.Instance.RegisterService(new RecipeUIFacade()); }
protected DefaultRepositoryHolder() { m_context = new CookbookMfContext(); m_recipeRepository = new DefaultEfRepository <Recipe>(m_context); m_recipeCategoryRepository = new DefaultEfRepository <RecipeCategory>(m_context); }