I have a query, which is defined like this, and I used it to generate a JSON output. The point is that, I have applied Distinct method to it, but it still shows duplicate items. For example, I have many items with value "Unclassifed", whereas I want only one of it, same goes for some other values. Here is my query:
var results = db.Users.OfType<Business>()
.Where(b => b.StateID == state && (term == null || b.Description.ToLower().Contains(term.ToLower())))
.Distinct().Select(x => new { id = x.StateID, value = x.Description }).Take(5).ToList();
Any idea, how to fix it? I guess I need to specifically apply Distinct to the value somehow.