15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

entity framework Mapping ❘ 865<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

code snippet BooksDemo/BooksModel.edmx<br />

The entity is defined by an EntityType element that contains Key, Property, <strong>and</strong> NavigationProperty<br />

elements to describe the properties of the created class. The Property element contains attributes to<br />

describe the name <strong>and</strong> type of the .<strong>NET</strong> properties of the classes that are generated by the designer. The<br />

Association element connects the types Author <strong>and</strong> Book. Multiplicity=“*” means that one Author can<br />

write multiple Books, <strong>and</strong> one Book can be written by multiple Authors.<br />

mapping layer<br />

The mapping layer maps the entity type definition from the CSDL to the SSDL by using the Mapping<br />

Specification Language (MSL). The following specification includes a Mapping element that contains the<br />

EntityTypeMapping element to reference the Book type of the CSDL <strong>and</strong> defines the MappingFragment to<br />

reference the Authors table from the SSDL. The ScalarProperty maps the property of the .<strong>NET</strong> class with<br />

the Name attribute to the column of the database table with the ColumnName attribute:<br />

<br />

<br />

<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!