public IList <Category> LoadRange(int startIndex, int count, SortDescriptionCollection sortDescriptions, out int overallCount) { var retVal = new List <Category>(); using (var repository = _repositoryFactory.GetRepositoryInstance()) { var query = repository.Categories.Expand("Catalog").OfType <Category>(); if (!String.IsNullOrEmpty(SearchName)) { query = query.Where(x => x.Name.Contains(SearchName)); } if (!String.IsNullOrEmpty(SearchCode)) { query = query.Where(x => x.Code.Contains(SearchCode)); } if (!String.IsNullOrEmpty(SearchCatalogId)) { query = query.Where(x => x.CatalogId == SearchCatalogId); } else if (SearchModifier.HasFlag(SearchCategoryModifier.RealCatalogsOnly)) { query = query.Where(x => x.Catalog is catalogModel.Catalog); } overallCount = query.Count(); var results = query.OrderBy(x => x.CatalogId).Skip(startIndex).Take(count); retVal.AddRange(results); } return(retVal); }
public void InitializeForOpen() { CanChangeSearchCatalog = SearchModifier.HasFlag(SearchCategoryModifier.UserCanChangeSearchCatalog) || (!(_catalogInfo is CatalogBase) && string.IsNullOrEmpty(_catalogInfo as string)); if (_catalogInfo is CatalogBase && !CanChangeSearchCatalog) { AvailableCatalogs = new List <CatalogBase> { (CatalogBase)_catalogInfo }; SearchCatalogId = AvailableCatalogs[0].CatalogId; } else { if (_catalogInfo is CatalogBase) { SearchCatalogId = ((CatalogBase)_catalogInfo).CatalogId; } else if (!string.IsNullOrEmpty(_catalogInfo as string)) { SearchCatalogId = (string)_catalogInfo; } using (var repository = _repositoryFactory.GetRepositoryInstance()) { var query = repository.Catalogs; if (!string.IsNullOrEmpty(SearchCatalogId) && !CanChangeSearchCatalog) { query = query.Where(x => x.CatalogId == SearchCatalogId); } else { if (SearchModifier.HasFlag(SearchCategoryModifier.RealCatalogsOnly)) { query = query.OfType <catalogModel.Catalog>(); } query = query.OrderBy(x => x.Name); } AvailableCatalogs = query.ToList(); } } SearchCommand = new DelegateCommand(DoSearch); ClearFiltersCommand = new DelegateCommand(DoClearFilters); SelectCommand = new DelegateCommand <Category>(RaiseSelectInteractionRequest); ListItemsSource = new VirtualList <Category>(this, 20, SynchronizationContext.Current); }