Freigeben über


4.2.2.1 Retrieve a Single Entity with a Mapped Property by Using the AtomPub Format

The following example illustrates the exchange of messages required for a client to retrieve an Employee entity with an EntityKey value equal to 1 by using the AtomPub format. The EmployeeName property and the City property of the Address complex-type property on the Employee EntityType have been mapped to another element by using the customizable feeds attributes that are included in the CSDL file. One of the property mappings on the Employee EntityType has the FC_KeepInContent attribute set to "false" and, as a result, the following exchange of messages is supported only in OData 2.0 and OData 3.0.

Request:

 GET /service.svc/Employees(1) HTTP/1.1
 Host: host
 Accept: application/atom+xml
 DataServiceVersion: 1.0
 MaxDataServiceVersion: 2.0

Response:

 HTTP/1.1 200 OK
 Date: Fri, 12 Dec 2008 17:17:11 GMT
 Content-Type: application/atom+xml;type=entry
 Content-Length: nnn
 ETag: W/"X'000000000000FA01'"
 DataServiceVersion: 2.0
  
 <?xml version="1.0" encoding="utf-8"?>
 <entry xml:base="http://host/service.svc/"
        xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
        xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
        xmlns:gml=http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd
        xmlns="http://www.w3.org/2005/Atom" m:etag="W/"X'000000000000FA01'"">
   <category term="SampleModel.Employee"
             scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
   <id>http://host/service.svc/Employees(1)</id>
   <title type="text"> Nancy Davolio</title>
   <updated>2008-03-30T21:32:23Z</updated>
   <author>
     <name />
   </author>
   <link rel="edit" title="Employees" href="Employees(1)/SampleModel.Employee" />
   <content type="application/xml">
    <m:properties>
     <d:EmployeeID>ALFKI</d:EmployeeID>
     <d:Address>
       <d:Street>507 - 20th Ave. E. Apt. 2A<d:Street>
       <d:City>Seattle</d:City>
       <d:Location m:type="Edm.GeographyPoint"><gml:Point srsName="4326">-127.345345 48.23423</gml:Point></d:Location>
     </d:Address>
     <d:Version>BBBBBBBB+gE=</d:Version>
    </m:properties>
   </content>
   <emp:Location xmlns:emp="http://www.microsoft.com">Seattle</emp:Location>
 </entry>