Catel.Extensions.EntityFramework5

Topics: Questions
Mar 14, 2013 at 9:00 AM
Edited Mar 14, 2013 at 9:52 AM
Found the new extension in the help files. First I was glad to see that in catel. I use catel and also entityframwork and was in search of an solution for uow.

But:
I don't want that my Application knows directly what ist the datasource. So at the moment I use the servicelocator to resolve a type named IRecipeDataManager. Thats one of my Repositorys.
using (var recipeDataManager = ServiceLocator.ResolveType<IRecipeDataManager>() )
{
     var recipes = recipeDataManager.GetRecipes();
}
My Implementation of IRecipeDataManager
    public class RecipeDataManager : IRecipeDataManager
    {
        public RecipeDataManager(ConfigurationContext context)
        {
            _dbContext = context;
        }
        public IEnumerable<Recipe> GetRecipes()
        {
            return _dbContext.Recipes.OrderBy(r => r.Name);
        }
    }
So I'am independent of Entityframwork and can easily change to an other datasource.

So my question: How can I use the UoW of catel and also be independent in my bussines code of entityframework.

Maybe you can help me and can give me some tipps

Thanks.
Coordinator
Mar 15, 2013 at 7:06 PM
I think that striving to "independency of EF" is not something you should go for. I have never seen a project where a change from ORM tool was done without pain (in the end, if you don't need to modify the software, you will need to modify the DataManagers.

The repositories are not inside a generic base. What might be possible in the future is that we move the base repositories with query behavior to the Data extension. Then we implement that in the EF extension and create another layer which allows extensibility to other ORM tools.

Don't expect this in the near future or maybe don't expect it at all. At the moment it has no priority for us.