| Single() / SingleOrDefault() | First () / FirstOrDefault() |
|
Single(): There is exactly 1 result, an exception is thrown if no result is returned or more than one result. SingleOrDefault(): Same as Single(), but it can handle the null value. |
First(): There is at least one result, an exception is thrown if no result is returned. FirstOrDefault(): Same as First(), but not thrown any exception or return null when there is no result. |
| Single() asserts that one and only one element exists in the sequence. | First() simply gives you the first one. |
|
When to use? Use Single / SingleOrDefault() when you are sure there is only one record present in a database or you can say if you querying on a database with the help of the primary key of the table. |
When to use? Developers may use First () / FirstOrDefault() anywhere when they require a single value from a collection or database. |
| Single() or SingleOrDefault() will generate a regular TSQL like "SELECT ...". | The First() or FirstOrDefault() method will generate the TSQL statement like "SELECT TOP 1..." |
| In the case of Fist / FirstOrDefault, only one row is retrieved from the database so it performs slightly better than single / SingleOrDefault. such a small difference is hardly noticeable but when a table contains a large number of columns and rows, at this time performance is noticeable. | |
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

mohamed alyamanyPosted Sep 9, 2021, 8:33 AM
Nice , Helpfull Information
Adhi VenkateshPosted Sep 10, 2020, 3:36 AM
Valuable article, thanks for shared.
Mujahid Al-ZakwaniPosted Apr 9, 2020, 11:36 PM
Thanks alot
Anamitra Bardhan RoyPosted Mar 9, 2020, 2:53 AM
Hi Jignesh Trivedi, Can you please help understand the performance glitch with reason as cited by Marcus Talcott' in below link where Single is always functioning better than First. I can no way figure a justification. Link : https://stackoverflow.com/questions/2724096/linq-single-vs-first
Aliya khanPosted Aug 23, 2019, 4:47 AM
Can Single/SingleOrDefault retrieve more than one row?
navneet SinghPosted May 7, 2018, 2:09 AM
Nice describtion...
Akhil KumarPosted Apr 5, 2017, 3:31 AM
Many thanks Jignesh
Mark MedinaPosted Mar 17, 2017, 1:33 PM
Very helpful. . thanks!
Nigel FernandesPosted Mar 6, 2017, 10:43 PM
Just read it, thanks .
Anupam SinghPosted Aug 6, 2014, 4:37 AM
nice..
Cristiano NascimentoPosted Feb 16, 2013, 12:12 PM
great post
Mario SaccoiaPosted Feb 15, 2013, 9:14 AM
good post!!!