<p>I am digging into LINQ--trying to understand basic models (it seems pretty cool to me). The code below is the code to perform before committing an update.   </p>

<pre><code>   Linq01.Account acc = context.Accounts.Single( pc =&gt; pc.AccountID == AccountID );
   acc.Name = textboxAccountNameRead.Text.Trim();
   context.SubmitChanges();
</code></pre>

<p>So far, so good. But what do you do if the Single() method failed--if the account ID wasn't found? </p>

<p>Thank you!</p>

You should use
```
SingleOrDefault
```
, if the query does not return a value you can check it against null:
```
```
var acc = context.Accounts.SingleOrDefault(pc => pc.AccountId == AccountId);
if(acc != null)
{
  acc.Name = textboxAccountNameRead.Text.Trim();
  context.SubmitChanges();
}
```
```