with help from Lost In
LoC
172 private static readonly char[] SplitDelimiters = " ".ToCharArray();
...
215 private IQueryable<Talent> BasicSearch(string searchExpression)
216 {
217 IQueryable<Talent> t;
218 string[] sa = searchExpression.Trim().Trim()
.ToLower()
.Split(SplitDelimiters,
StringSplitOptions.RemoveEmptyEntries);
219 t = _repository.GetTalents();
220 foreach (string s in sa)
221 {
222 t = t.Intersect(AddBasicSearch(s), new TalentComparer());
223 //http://lostinloc.com/2008/02/06/the-principle-of-least-astonishment/
224 }
225 return t;
226 }
13 public class TalentComparer : IEqualityComparer<Talent> // defines Equals and GetHashCode
14 {
15 public bool Equals(Model.Model.Talent x, Model.Model.Talent y)
16 {
17 return x.Id == y.Id;
18 }
19
20 // implements the IEqualityComparer.GetHashCode(T obj) : int
21 public int GetHashCode(Model.Model.Talent obj)
22 {
23 return obj.Id.GetHashCode();
24 }
25 }
No comments:
Post a Comment