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.

864 ❘ ChaPTer 31 AdO.net entity frAmewOrk<br />

< Property Name="Publisher" Type="nvarchar" Nullable="false" MaxLength="50" / ><br />

< Property Name="Isbn" Type="nchar" MaxLength="18" / ><br />

< /EntityType ><br />

< EntityType Name="BooksAuthors" ><br />

< Key ><br />

< PropertyRef Name="BookId" / ><br />

< PropertyRef Name="AuthorId" / ><br />

< /Key ><br />

< Property Name="BookId" Type="int" Nullable="false" / ><br />

< Property Name="AuthorId" Type="int" Nullable="false" / ><br />

< /EntityType ><br />

< Association Name="FK_BooksAuthors_Authors" ><br />

< End Role="Authors" Type="BooksModel.Store.Authors" Multiplicity="1" / ><br />

< End Role="BooksAuthors" Type="BooksModel.Store.BooksAuthors" Multiplicity="*" / ><br />

< ReferentialConstraint ><br />

< Principal Role="Authors" ><br />

< PropertyRef Name="Id" / ><br />

< /Principal ><br />

< Dependent Role="BooksAuthors" ><br />

< PropertyRef Name="AuthorId" / ><br />

< /Dependent ><br />

< /ReferentialConstraint ><br />

< /Association ><br />

< Association Name="FK_BooksAuthors_Books" ><br />

< End Role="Books" Type="BooksModel.Store.Books" Multiplicity="1" / ><br />

< End Role="BooksAuthors" Type="BooksModel.Store.BooksAuthors" Multiplicity="*" / ><br />

< ReferentialConstraint ><br />

< Principal Role="Books" ><br />

< PropertyRef Name="Id" / ><br />

< /Principal ><br />

< Dependent Role="BooksAuthors" ><br />

< PropertyRef Name="BookId" / ><br />

< /Dependent ><br />

< /ReferentialConstraint ><br />

< /Association ><br />

< /Schema ><br />

< /edmx:StorageModels ><br />

code snippet BooksDemo/BooksModel.edmx<br />

The fi le BooksModel.edmx contains SSDL, CSDL, <strong>and</strong> MSL. You can open this fi le<br />

with an XML editor to see its contents.<br />

Conceptual layer<br />

The conceptual layer defi nes .<strong>NET</strong> classes. This layer is created<br />

with the Conceptual Schema Defi nition Language (CSDL).<br />

Figure 31 - 2 shows the entities Author <strong>and</strong> Book defi ned with the<br />

ADO.<strong>NET</strong> Entity Data Model Designer.<br />

The following is the CSDL content that defi nes the entity types<br />

Book <strong>and</strong> Author . This was created from the Books database:<br />

figure 31-2<br />

< edmx:ConceptualModels ><br />

< Schema Namespace="BooksModel" Alias="Self"<br />

xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation"<br />

xmlns="http://schemas.microsoft.com/ado/2008/09/edm" ><br />

< EntityContainer Name="BooksEntities" annotation:LazyLoadingEnabled="true" ><br />

< EntitySet Name="Authors" EntityType="BooksModel.Author" / ><br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!