title: Entity Framework 5 - Local BindingList - Filtering?
body: <p>Hopefully someone can point out how to do this:</p>
  
  <p>I have a WinForms application that uses Entity Framework. We e.g. have data bound to a gridControl via a repository that delivers a BindingList.</p>
  
  <p>e.g. (simplified code)</p>
  
  <pre><code>class ProductRepository {
     public void LoadAll() {
             _context.Products.Where(p =&gt; p.Deleted == false).Load();
     }
  
     public BindingList&lt;T&gt; GetBindingList() {
             LoadAll();
             return _context.Products.Local.ToBindingList();
     }
  }
  
  class ProductListPresenter {
      private void SetList() {
         _view.SetList(productRepo.GetBindingList());
      }
  }
  
  class ProductListView {
       DeletedButton.Click += {
           (bindingSource1.Current as Product).Deleted = 1;
           gridControl1.Refresh();
       };
  }
  </code></pre>
  
  <p>BUT: I only want to display non deleted Products (Product.Deleted == false). It is okay to filter it within the Repository Load() method, but how do I filter it when I already bound it to my control? I can't do bindingSource1.RemoveCurrent() as it would completely wipe the Entity and mark it as State.Deleted..</p>
  
  <p>Another thing to consider here is: I have some other things going on in that form and I need all the changes committed in the database only when the user decides to save the changes by clicking on the "save"-button. I kind of have to work with an in memory state until the user explicitly saves the changes.</p>
  
  <p>Any suggestions? Using EF in WinForms is somehow starting to raise the frustration level..</p>