2010-08-11 1 views
0

저는 엔터티 세트에서 단일 엔터티를 가져 오는 중 Silverlight 4를 사용하고 있습니다. 힘들지 않니?! 나는 때문에 나무의 숲을 볼, 또는 정말 같은 추악한 일을해야하지Silverlight 4 RIA Services - EntitySet에서 첫 번째 엔터티를 선택하십시오.

myDomainContext dc = new OrgUnitTestDomainContext(); 
OrgUnit ou; 
ou=dc.OrgUnits[0]; //Error 1 The property or indexer 'System.ServiceModel.DomainServices.Client.EntitySet.List' cannot be used in this context because the get accessor is inaccessible 
ou=dc.OrgUnits.First; //Error 2 ... does not contain a definition for 'First' and no extension method 'First' accepting a first argument 
ou=dc.OrgUnits.Current; //Error 3 ... does not contain a definition for 'Current' and no extension method 'Current' accepting a first argument 
ou=dc.OrgUnits.List.First; //Error 4 The property or indexer 'System.ServiceModel.DomainServices.Client.EntitySet.List' cannot be used in this context because the get accessor is inaccessible 
ou=dc.OrgUnits.List.Current; //as Error 3 

를 수행합니다 :

//That works 
System.Collections.Generic.IEnumerator<OrgUnit> enu = dc.OrgUnits.GetEnumerator(); 
enu.MoveNext(); 
ou = enu.Current; 

//That works, but its ugly, too 
foreach (OrgUnit ou in dc.OrgUnits) 
{ 
    SelectedOrgUnit = ou; 
    break; 
} 

사람을 가지고 글쎄, 난 단순히 작업을 얻을 수 없다 거기에 뭐가 잘못 됐는지 생각해 봅니다 - 말했듯이, 나는 단지 하나의 실재물을 얻으려고 노력하고 있습니까? 안녕하십니까, rwh

답변

0

DomainContext에 데이터를로드하지 않았습니다. 필요한 데이터를로드 할 때까지는 비어 있습니다. (XAML에서 그렇게하지 않는 한 ??)

+0

안녕하세요. 힌트를 보내 주셔서 감사합니다. 사실, 선언은 입니다. myDomainContext dc = new OrgUnitTestDomainContext(); 은 다른 곳에서 dc의 의미를 명확히하기 위해 복사했습니다. 다른 모든 행은 OnOrgUnitsLoaded에 있으며,로드가 완료 되 자마자 호출됩니다. 댓글에 표시된 오류 메시지는 이미 designtime에 표시되어 있으므로 다른 방법이 있습니다. – rwh