The subject of this chapter is queries, but in a real application, you don’t just run queries for their own sake; you want to do something with the results. That’s not always as straightforward as it might appear, but the
DbSet.Local property makes it simpler:
You can bind directly to the context (once you’ve loaded the data), but that presents some problems if you want to run additional queries, for example to allow your users to find a specific entity. The problem is that the
DbSet are actually queries. Think about what happens if you execute code like this:
Recipe theRecipe = (from r in context.Recipes where ...