Beispiel #1
0
        public void Filter()
        {
            if (searchName == null)
            {
                searchName = string.Empty;
            }

            var result = ProfessorsLocal.Where(p => p.Name.ToLowerInvariant().Contains(SearchName.ToLowerInvariant()))
                         .ToList();

            if (result != null)
            {
                var remove = Professors.Except(result).ToList();

                remove.ForEach(r =>
                {
                    Professors.Remove(r);
                });
            }

            for (int index = 0; index < result.Count; index++)
            {
                var item = result[index];
                if (index + 1 > Professors.Count || !Professors[index].Equals(item))
                {
                    Professors.Insert(index, item);
                }
            }
        }