title: WPF Architecture with Business Layer and DAL
body: <p>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.</p>
  
  <p>• 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.</p>
  
  <p>• 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.</p>
  
  <p>• 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:</p>
  
  <pre><code>public class ContextCreator : IDisposable
  {
      private MesaOperativaDB context;
  
      public ContextCreator()
      {
          context = new MesaOperativaDB();
      }
  
      public MesaOperativaDB getContext()
      {
          return context;
      }
  
      public void Dispose()
      {
          context.Dispose();
      }
  }
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>    public static List&lt;Novedades&gt; GetNovedades()
      {
          using (ContextCreator db = new ContextCreator())
          {
              IQueryable&lt;Novedades&gt; novedades = db.getContext().Set&lt;Novedades&gt;().AsQueryable();
              return novedades.ToList();
          }
      }
  </code></pre>
  
  <p>Is this approach any good?
  Thank you in advance guys.</p>