Comma
Comma

Reputation: 1607

linq to sql ToList() method value

when there's no rows returned from the database. Will I always get a List object of Count = 0. Will there ever be a case where the List = null?

Upvotes: 2

Views: 538

Answers (2)

Igor Zevaka
Igor Zevaka

Reputation: 76570

The list will never be null. LINQ operations are fluent, hence having a list returning null can break chains of operations.

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1039378

You will always get an empty list and never null if there are no rows.

Upvotes: 1

Related Questions