O'Reilly logo

Fluent Entity Framework by Rebecca M. Riordan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working locally

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 EntitySet and DbSet are actually queries. Think about what happens if you execute code like this:

Image

Recipe theRecipe = (from r in context.Recipes         where ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required