IList ApplyFilter(List <Contact> list, AlphaIndex alpha) { if (alpha == null || alpha == AlphaIndex.All) { return(list); } var res = from q in list where alpha.Match(extractName(q)) select q; return(res.ToList()); }
protected void InitIndex(List <Contact> list) { this.extractName = (s) => { string name = ((Contact)s).LastName; if (string.IsNullOrEmpty(name)) { return(null); //todo? } return(AlphaIndex.Group(name.Substring(0, 1))); }; List <AlphaIndex> dict = Generate(list, extractName); SetupGrid(dict, indexGridControl); }
IList ApplyFilter(List<UserInfo> list, AlphaIndex alpha) { if(alpha == null || alpha == AlphaIndex.All) return list; var res = from q in list where alpha.Match(extractName(q)) select q; return res.ToList(); }