0
我正在使用WCF數據服務。使用新命名空間自定義OData xml
在我的OData服務的實體默認飼料屬性是
<feed xml:base="http://localhost:54527/DataModel.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
如何添加自己的名字空間這份名單在飼料財產?
我試圖讓我的odata服務GeoRSS兼容,我已經添加了一些EntityPropertyMappingAttribute的使數據兼容,但它沒有被我們正在使用的工具識別。
現在它生產的:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<feed xml:base="http://localhost:54527/DataModel.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Collars</title>
<id>http://localhost:54527/DataModel.svc/Collars</id>
<updated>2011-11-07T09:23:05Z</updated>
<link rel="self" title="Collars" href="Collars" />
<entry>
<id>http://localhost:54527/DataModel.svc/Collars(HOLEID='ABL001',PROJECTCODE='ACA')</id>
<title type="text"></title>
<updated>2011-11-07T09:23:05Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Collar" href="Collars(HOLEID='ABL001',PROJECTCODE='ACA')" />
<category term="Neo.Collar" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:HOLEID>ABL001</d:HOLEID>
<d:PROJECTCODE>ACA</d:PROJECTCODE>
<d:TENEMENTID>5853</d:TENEMENTID>
<d:LAT>116.49531406</d:LAT>
<d:LONG>-21.65159678</d:LONG>
</m:properties>
</content>
<geo:lat xmlns:geo="http://www.georss.org/georss">116.49531406</geo:lat>
<geo:long xmlns:geo="http://www.georss.org/georss">-21.65159678</geo:long>
</entry>
但我寧願有地理命名了頂部:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<feed xml:base="http://localhost:54527/DataModel.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"
xmlns:geo="http://www.georss.org/georss">
<title type="text">Collars</title>
<id>http://localhost:54527/DataModel.svc/Collars</id>
<updated>2011-11-07T09:23:05Z</updated>
<link rel="self" title="Collars" href="Collars" />
<entry>
<id>http://localhost:54527/DataModel.svc/Collars(HOLEID='ABL001',PROJECTCODE='ACA')</id>
<title type="text"></title>
<updated>2011-11-07T09:23:05Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Collar" href="Collars(HOLEID='ABL001',PROJECTCODE='ACA')" />
<category term="Neo.Collar" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:HOLEID>ABL001</d:HOLEID>
<d:PROJECTCODE>ACA</d:PROJECTCODE>
<d:TENEMENTID>5853</d:TENEMENTID>
<d:LAT>116.49531406</d:LAT>
<d:LONG>-21.65159678</d:LONG>
</m:properties>
</content>
<geo:lat>116.49531406</geo:lat>
<geo:long>-21.65159678</geo:long>
</entry>
我可能會對此完全錯誤的方式。 謝謝。
你能澄清你爲什麼要添加命名空間嗎?只有在使用了名稱空間的情況下才有意義,這意味着要更改序列化,並且在這種情況下,所有使用的名稱空間都將被自動包含。 –
增加了一些我想要實現的更多細節。 – Sigh
舉例來說,這個OData源代碼完全是我想要實現的關於地理名稱空間的命名空間,它可以被我們正在使用的geo rss工具使用。 http://www.commuterapi.com/Wiki/developer-resources和http://transit.cloudapp.net/DevTransitODataService.svc/Stops – Sigh