The major difference between First and FirstOrDefault is that First() will throw an exception if there is no result data for the supplied criteria whereas FirstOrDefault() will return the default value (null) if there is no result data.
First() will throw an exception if there is no result data, as you can see below.
FirstOrDefault() returns the default value (null) if there is no result data and you can see the result in the following screen.
No comments:
Post a Comment