The LINQ query looks the same as any other query that filters based on name. We then
use the Singlemethod to let Entity Framework know that we expect a single result. If
the query returns no results, or more than one result, an exception will be thrown. If
there are potentially no matches, you can use the SingleOrDefault method, which will
return null if no results are found. Example 2-16 shows the FindGreatBarrierReef
method updated to account for the fact it may not exist in the database.
If two rows are found, Singleand SingleOrDefault will throw an error because there is not a
single result. If you just want the first result, and aren’t concerned if there is more than
one result, you can use Firstor FirstOrDefault.
Software engineering and business solutions blog featuring SaaS reviews, automation tools, and business insurance guides. Buyer-intent content designed to drive high-quality traffic and conversions.
Subscribe to:
Post Comments (Atom)
Python Logging Best Practices
Python Logging Best Practices Introduction to Python Logging Importance of Logging in Business Applications Logging is an essential ...
-
How to clear SharePoint People Picker suggestion cache If you have been SharePoint Site owner long enough, you would have definitely ...
-
Getting the following error (Figure 1): Server Error in '/' Application. ID4014: A SecurityTokenHandler is not registered to ...
-
The problem was that the remote connection needed to utilize Named Pipes, but in order to utilize Named Pipes both the machine hosting the i...
No comments:
Post a Comment