Advertisement
RichardD

ViewModel

Oct 4th, 2011
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement