private void Filter(object param) { using (var db = new DB.DomenaDBContext()) { Apartments.Clear(); IQueryable <Apartment> q = db.Apartments.Where(x => x.IsDeleted == false && x.SoldDate == null); if (SelectedBuildingName != null) { q = q.Where(x => x.BuildingId == SelectedBuildingName.BuildingId); } if (SelectedOwnerName != null) { q = q.Where(x => x.OwnerId == SelectedOwnerName.OwnerId); } InitializeApartments(q); } }