I have a list of books, each book has a author assigned to it.
What I'm trying to do is allow the user the filter the results based on the author.
So some books may have the same Author etc but I want to filter the Authors out only show and entry for each one in my dropdown.
This is what I currently have :
var bookAuthors = Cache.CacheExtension.GetFromCache<List<BookCollection>>("books"); // Returns me the collection of books
// Filter the Authors out of the books
var authorCollection = bookAuthors.DistinctBy(item => new Options { Id = item.BookAuthor.ToString(), Description = item.BookAuthor }).ToList(); // Doesn't remove duplicates
As you can see I'm using DistinctBy but nothing gets filtered.
If I do this
var authorCollection = bookAuthors.Select(item => new Options { Id = item.BookAuthor.ToString(), Description = item.BookAuthor }).ToList(); // I get a list of Authors.
I get the list but it contains duplicates, any help would be grand