Im starting a new application in WPF and I want it to have a good architecture so that it can be maintainable. Im using Entity Framework and what I planned so far is.
• View Layer: One project (startup) with the startup view, and main menus. Different projects for each type of view, for example, if I have views related with Books then I'd have a project named BooksView with all the views.
• Business Layer: One project for each type of Business Class, for example BusinessBooks. Each one would have a Repository with the specific operations and any helpers to do calculations if needed.
• Data Acess Layer: It contains a folder named Entity Framework with the DBContext and with the T4 generated classes and with a class named ContextCreator which has the following code:
public class ContextCreator : IDisposable
{
private MesaOperativaDB context;
public ContextCreator()
{
context = new MesaOperativaDB();
}
public MesaOperativaDB getContext()
{
return context;
}
public void Dispose()
{
context.Dispose();
}
}
Then a view would use the static repository of any project of the Business Layer that needs, and this repository would use the class above to get the DBContext and use it like this:
public static List<Novedades> GetNovedades()
{
using (ContextCreator db = new ContextCreator())
{
IQueryable<Novedades> novedades = db.getContext().Set<Novedades>().AsQueryable();
return novedades.ToList();
}
}
Is this approach any good? Thank you in advance guys.