15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

31<br />

aDo.neT entity framework<br />

WhaT ’ s in This ChaPTer<br />

➤<br />

➤<br />

➤<br />

➤<br />

➤<br />

➤<br />

➤<br />

➤<br />

The ADO.<strong>NET</strong> Entity Framework<br />

Mapping between database tables <strong>and</strong> entity classes<br />

Creating entity classes <strong>and</strong> their features<br />

Object contexts<br />

Relationships<br />

Object queries<br />

Updates<br />

LINQ to Entities<br />

The ADO.<strong>NET</strong> Entity Framework is an object - relational mapping framework that offers an<br />

abstraction of ADO.<strong>NET</strong> to get an object model based on the referential databases. This chapter<br />

gives information on the mappings between the database <strong>and</strong> the entity classes using the Conceptual<br />

Schema Defi nition Language (CSDL), Storage Schema Defi nition Language (SSDL), <strong>and</strong> the<br />

Mapping Schema Language (MSL). Different relationships between entities are covered, such as<br />

one Table-per-Hierarchy of objects, one Table-per-Type, <strong>and</strong> n - to - n relationships.<br />

This chapter also describes different ways to access the database from the code directly with the Entity<br />

Client, using Entity SQL or helper methods that create Entity SQL, <strong>and</strong> using LINQ to Entities. Object<br />

tracking <strong>and</strong> how the data context holds change information for updating data is also shown.<br />

This chapter uses the Books, Formula1, <strong>and</strong> Northwind databases. You can download<br />

the Northwind database from msdn.microsoft.com; the Books <strong>and</strong> Formula1 databases<br />

are included with the download of the code samples at http://www.wrox.com.<br />

oVerVieW of The ado.neT enTiTy frameWorK<br />

The ADO.<strong>NET</strong> Entity Framework provides a mapping from the relational database schema to objects.<br />

Relational databases <strong>and</strong> object - oriented languages defi ne associations differently. For example,<br />

the Microsoft sample database Northwind contains the Customers <strong>and</strong> Orders tables. To access all<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!