private void InitializeCollection() { Charges = new ObservableCollection<ChargeDataGrid>(); using (var db = new DB.DomenaDBContext()) { //var qa = db.Charges.Include(c => c.Components).Where(x => x.IsClosed).FirstOrDefault(); var q = db.Charges.Include(x => x.Components).Include(x => x.Components.Select(y => y.GroupName)).Where(x => !x.IsDeleted); foreach (var ch in q) { var cdg = new ChargeDataGrid(ch); Charges.Add(cdg); } } ChargesCV = (CollectionView)CollectionViewSource.GetDefaultView(Charges); ChargesCV.SortDescriptions.Add(new SortDescription("CreatedTime", ListSortDirection.Ascending)); ChargesCV.Filter = FilterCollection; if (GroupByApartment) { ChargesCV.GroupDescriptions.Add(new PropertyGroupDescription("Apartment.ApartmentNumber")); } if (GroupByBuilding) { ChargesCV.GroupDescriptions.Add(new PropertyGroupDescription("Building.Name")); } ChargesCV.Refresh(); }
private void ClearFilter(object param) { SelectedOwnerName = null; SelectedBuildingName = null; SelectedApartmentNumber = null; ChargesCV.Refresh(); }
private void InitializeCollection() { Charges = new ObservableCollection <ChargeDataGrid>(); using (var db = new DB.DomenaDBContext()) { foreach (var apartment in db.Apartments.Where(x => !x.IsDeleted)) { var c = Helpers.ChargesOperations.CreateMonthlyCharge(apartment); var cdg = new ChargeDataGrid(c); Charges.Add(cdg); } } ChargesCV = (CollectionView)CollectionViewSource.GetDefaultView(Charges); ChargesCV.SortDescriptions.Add(new SortDescription("Apartment.ApartmentNumber", ListSortDirection.Ascending)); ChargesCV.Filter = FilterCollection; if (GroupByApartment) { ChargesCV.GroupDescriptions.Add(new PropertyGroupDescription("Apartment.ApartmentNumber")); } if (GroupByBuilding) { ChargesCV.GroupDescriptions.Add(new PropertyGroupDescription("Building.Name")); } ChargesCV.Refresh(); }