O'Reilly logo

Programming Entity Framework, 2nd Edition by Julia Lerman

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

Chapter 3. Querying Entity Data Models

You can query Entity Data Models in a variety of ways. Some ways you will choose for personal preference and others you will choose so that you can leverage particular benefits. You have likely heard of LINQ to Entities and Entity SQL. You can also use special methods (some based on LINQ and others based on the Entity Framework’s ObjectQuery class) to express queries. Each of these query styles will result in materialized objects. There is a lesser-known means of querying using Entity Framework’s EntityClient API, which allows you to stream raw data back to your applications.

In this chapter, you will get a chance to try out all of these different styles of querying. You will repeat a few simple queries using the various mechanisms and look at the results so you can see how the different query methods relate to one other.

By the end of this chapter, you will have gained a high-level understanding of all of the query options and their basic uses. In further chapters, you will write more complex queries; the foundation you will receive from this chapter will make that task much easier. In addition, at the end of this chapter you’ll find a critical lesson on query execution.

Although the query examples in this chapter are presented within a console application, you can use LINQPad to test the queries and see the results. Some of the guidance in this chapter will also inspect the debugger, which you will not be able to do in LINQPad. See the sidebar ...

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