Apress

Entity Framework 4.0 Recipes

A Problem-Solution Approach

By Larry Tenny , Zeeshan Hirani

Entity Framework 4.0 Recipes Cover Image

With this book, you will learn the core concepts of Entity Framework through a broad range of clear and concise solutions to everyday data access tasks. Armed with this experience, you will be ready to dive deep into Entity Framework, experiment with new approaches, and develop ways to solve even the most difficult data access challenges.

Full Description

  • ISBN13: 978-1-4302-2703-8
  • 648 Pages
  • User Level: Beginner to Intermediate
  • Publication Date: May 5, 2010
  • Available eBook Formats: EPUB, MOBI, PDF
  • Print Book Price: $54.99
  • eBook Price: $38.99
Buy eBook Buy Print Book Add to Wishlist

Related Titles

Full Description

Entity Framework 4.0 Recipes provides an exhaustive collection of ready-to-use code solutions for Entity Framework, Microsoft’s vision for the future of data access. Entity Framework is a model-centric data access platform with an ocean of new concepts and patterns for developers to learn. With this book, you will learn the core concepts of Entity Framework through a broad range of clear and concise solutions to everyday data access tasks. Armed with this experience, you will be ready to dive deep into Entity Framework, experiment with new approaches, and develop ways to solve even the most difficult data access challenges. If you are a developer who likes to learn by example, then this is the right book for you.

  • Gives ready-to-use, real-world recipes to help you with everyday tasks
  • Provides guideposts for learning core concepts
  • Maps out key landmarks for experimenting with your own solutions

What you’ll learn

  • Solve the most common data access problems using Entity Framework.
  • Implement basic data access design patterns using Entity Framework.
  • Seamlessly model your solutions across both code and data.
  • Improve data access performance.
  • Use data binding to simplify and reduce your code.
  • Leverage the recipes to empower your own exploration of Entity Framework.

Who this book is for

This book is for anyone learning Microsoft’s Entity Framework—Microsoft’s primary data access platform. If you have ever struggled to learn a new technology, programming model, or way of doing something, you know how helpful simple, real-world examples can be. For the beginning developer, this book provides concrete examples for common data access tasks. For developers with experience with previous Microsoft access platforms, this book provides a task-by-task mapping between previous approaches and the patterns used in Entity Framework.

Table of Contents

Table of Contents

  1. Getting Started With Entity Framework
  2. Entity Data Modeling Fundamentals
  3. Querying an Entity Data Model
  4. Using Entity Framework in ASP.NET
  5. Loading Entities and Navigation Properties
  6. Beyond the Basics with Modeling and Inheritance
  7. Working with Object Services
  8. Plain Old CLR Objects
  9. Using the Entity Framework in N-Tier Applications
  10. Stored Procedures
  11. Functions
  12. Customizing Entity Framework Objects
  13. Improving Performance
  14. Concurrency
  15. Advanced Modeling
Source Code/Downloads

Downloads are available to accompany this book.

Your operating system can likely extract zipped downloads automatically, but you may require software such as WinZip for PC, or StuffIt on a Mac.

Errata

If you think that you've found an error in this book, please let us know about it. You will find any confirmed erratum below, so you can check if your concern has already been addressed.

* Required Fields

On page 41:

Error / incomplete / mileading sourcecode chapter 2-7.

It is not necessary to include PhotoId for the PhotographFullImage. In fact even a wrong PhotoId here makes no difference, it is accepted and never used, and no error pops up.

This is because of the way you relate the objects:
photo.PhotographFullImage = fullImage;
context.Photographs.AddObject(photo);

If you instead write as follows, then the PhotoId is used and needed:
context.Photographs.AddObject(photo);
context.PhotographFullImageSet.AddObject(fullImage);


On page 41:

Microoft must-be error.

I changed the high resolution image to a 100 000 000 byte array.

Accessing this byte array directly in for loop, or using its length property directly in the for loop failed totally. When only accessing the Length property in the for loop it appeared that 100's of MB where copied & deleted internally for each acces of the Length property. The thing never finished, Visual Studio hanged.

This code flies along:
byte[] fullBits = new byte[100000000];
photo.HighResolutionBits.CopyTo(fullBits, 0);
int len = photo.HighResolutionBits.Length;
for (int n = 0; n < len; n++)
{
fullBits[n] += fullBits[n];
}

This code fails big-time, never finishes:
byte[] fullBits = new byte[100000000];
for (int n = 0; n < photo.HighResolutionBits.Length; n++)
{
fullBits[n] += n;
}

This fails to finish also:
byte[] fullBits = new byte[100000000];
photo.HighResolutionBits.CopyTo(fullBits, 0);
int len = photo.HighResolutionBits.Length;
for (int n = 0; n < len; n++)
{
fullBits[n] += photo.HighResolutionBits[n];
}

Debug or Release mode make no difference.


On page 95:
In Recipe 3-12 "Applying a Left Outer Join" the resulting set does not seem to represent a Left Outer Join.

The text implies that all Products should be returned regardless of whether or not a related TopSelling Entity exists. If it were a Left Outer Join the expected result set would include the product "Trailrunner Backpack".