0
我想通過我的WCF數據服務中的WebGet操作返回一個簡單的對象(它是在EF 4中的EDMX中創建的)。我能夠看到該對象,但是作爲對象的屬性沒有填充(int這種情況下DisplaySize是空的,即使我已經設置了它)。我計劃進行數據庫調用來從非-EF生成的表,因爲我們不是所有的數據遷移到新的架構還沒有(請推斷此對象類型)如何從WCF數據服務Webget返回實體框架實體?
[WebGet]
[SingleResultAttribute]
public Display GetDisplay(int displayId)
{
Display foundDisplay = new Display();
foundDisplay.DisplaySize = new DisplaySize() { Id = 1, Width = 1024, Height = 768, Dimensions = "1024 X 768" };
foundDisplay.Id = displayId;
return foundDisplay;
}
的URL調用我使用:http://localhost:1354/services/EDMDataService.svc/GetDisplay?displayId=1 的XML從通話是:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="http://localhost:1354/services/EDMDataService.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">
<id>http://localhost:1354/services/EDMDataService.svc/Displays(1)</id>
<title type="text"></title>
<updated>2010-11-12T19:34:29Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Display" href="Displays(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/DisplaySize" type="application/atom+xml;type=entry" title="DisplaySize" href="Displays(1)/DisplaySize" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Address" type="application/atom+xml;type=entry" title="Address" href="Displays(1)/Address" />
<category term="DataModels.Display" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:DisplaySizeID m:type="Edm.Int32">0</d:DisplaySizeID>
<d:DisplayTypeID m:type="Edm.Int32">0</d:DisplayTypeID>
<d:TimeZoneID m:type="Edm.Int32" m:null="true" />
<d:Facing m:null="true" />
<d:PanelNumber m:type="Edm.Int32" m:null="true" />
<d:DisplayTemplateTypeID m:type="Edm.Int32">1</d:DisplayTemplateTypeID>
<d:DisplayGUID m:null="true" />
<d:RegistrationKey m:null="true" />
<d:FirmwareVersion m:null="true" />
<d:Id m:type="Edm.Int32">1</d:Id>
<d:Base m:type="DataModels.Base">
<d:Title>test</d:Title>
<d:Summary>Description would go here</d:Summary>
<d:DataCenterSiteID m:type="Edm.Int32">0</d:DataCenterSiteID>
</d:Base>
</m:properties>
</content>
</entry>