1
我有一個ADO.NET模型實體,它反映了一個Oracle數據庫和一個提供對此ADO.NET模型的訪問的WCF服務。在我的WCF服務代碼中,我有以下內容:從Silverlight中的WCF數據服務查詢數據錯誤
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
//config.SetServiceOperationAccessRule("MyServiceOperation",ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
我在我的silverlight 5應用程序中添加了對此服務的引用。然後在下面的代碼,我得到一個錯誤:
Uri WCFUri = new Uri(HtmlPage.Document.DocumentUri, "WcfDataService.svc");
WCF_Service.Entities Database = new WCF_Service.Entities(WCFUri);
var buildings = from building in Config.Database.BUILDINGs
select building.BLDG_ID;
var buildingsQuery = (DataServiceQuery<string>)buildings;
buildingsQuery.BeginExecute(buildingsResult =>
{
foreach (string buildingId in buildingsQuery.EndExecute(buildingsResult))
BuildingsList.Items.Add(new ListItem(buildingId.Trim(), false));
BuildingListBusyIndicator.IsBusy = false;
}, null);
的錯誤是:
Navigation properties can only be selected from a single resource. Specify a key predicate to restrict the entity set to a single instance.
我失去了什麼問題。提前致謝。
您會在哪一行發生此錯誤? – 2012-02-27 22:53:44
我現在不在我的電腦上工作,但我認爲這是 var buildings =從建築物的Config.Database.BUILDINGs select building.BLDG_ID; – Justin 2012-02-28 00:33:33