Accepted answer

Take will return a collection with n elements in it. You still need to iterate over that collection. In your case, the collection size is 1.

First will return the first item in the collection.

Extra Credit

If your collection is not already sorted use OrderBy

Book bookToDelete = Books.OrderBy(b => b.SomeDate).First();


just use FirstOrDefault():

var firstBook = Books.FirstOrDefault();

If there is no book in the collection, firstBook will be null, otherwise it will be set to the first item.

Typically you would want the first book by some criteria though, if so just use an appropriate Where clause beforehand:

var firstThriller = Books.Where(b => b.Type == "Thriller")


Take returns an IEnumerable<T> containing a single element, what you want is:


Which returns the first element (or null if Books is empty).


Take() returns an IEnumerable<Book>. As such, your attempt to cast it into a Book fails, returning a null value.

Use Books.First() or Books.FirstOrDefault() instead.

Clarification for Nitpickers: Take() may actually return an IQuerable<Book> if Books came directly from a DataContext.


I would just use


Instead of


The Take Extension method returns IQueryable<T> and you're trying to cast as T (Book). This is why you always get null.


Yes, you missed the First() extension method:

Book BookToDelete = Books.First();

Note that Take(int) returns a sequence of Books (IQueryable<T>) - even if that sequence contains just one item in your case. As there is no conversion from IQueryable<T> to T, as will return null.

Related Articles