You can use the GroupBy
overload that allows you to specify a case-insensitive comparer:
List<Book> distinct =
BookAttribute.GroupBy(a => a.Genre, StringComparer.OrdinalIgnoreCase)
.Select(g => g.First())
.ToList();
Depending on your scenario, you might also be able to use Distinct
:
List<string> distinctGenres =
BookAttribute.Select(a => a.Genre)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
Edit: You also need to alter the equality check in your initial query:
var loadbook = from Book s in BookDB.Books
where s.Genre.Equals(abc.Genre, StringComparison.OrdinalIgnoreCase)
select s;