I am making an ASP.NET MVC application, and for actions like Edit
or Details
that require a single item, is it better to use myDbContext.MyDbSet.Single(i => i.Id == id)
or myDbContext.MyDbSet.Find(id)
? The latter is shorter, and in my opinion, cleaner without requiring the Linq method, but sources I have been reading on ASP.NET MVC seem to prefer the former.
I can't find a way to view the implementation, but if I had to guess, I'd say that Single()
probably uses Find()
somewhere along the way, which would indicate more method calls and somewhat inferior efficiency/performance. Is my thinking on this correct?