Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

ViewModel

By: RichardD on Oct 4th, 2011  |  syntax: C#  |  size: 1.20 KB  |  views: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public sealed class SearchPeopleResultsViewModel : ViewModelBase
  2. {
  3.     private LinqAsyncDataSourceProvider _provider;
  4.     private PeopleContext _context;
  5.  
  6.     public SearchPeopleResultsViewModel()
  7.     {
  8.         _context = new PeopleContext();
  9.         _context.Configuration.ProxyCreationEnabled = false;
  10.         _context.Configuration.AutoDetectChangesEnabled = false;
  11.         _context.Configuration.LazyLoadingEnabled = false;
  12.  
  13.         IQueryable<Person> people = _context.People.AsNoTracking();
  14.         _provider = new LinqAsyncDataSourceProvider(people);
  15.     }
  16.  
  17.     public DataSourceProvider SearchResults
  18.     {
  19.         get { return _provider; }
  20.     }
  21.  
  22.     protected override void Dispose(bool disposing)
  23.     {
  24.         try
  25.         {
  26.             if (disposing)
  27.             {
  28.                 if (null != _provider)
  29.                 {
  30.                     _provider.Dispose();
  31.                     _provider = null;
  32.                 }
  33.  
  34.                 if (null != _context)
  35.                 {
  36.                     _context.Dispose();
  37.                     _context = null;
  38.                 }
  39.             }
  40.         }
  41.         finally
  42.         {
  43.             base.Dispose(disposing);
  44.         }
  45.     }
  46. }
  47.