Hi, I'm working with Silverlight 4 on getting a single entity from an Entity Set. Doesn't sound hard?! Well, I simply can't get it working:
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
Don't I see the forest because of the trees, or do I really have to do ugly things like:
//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;
}
Has anyone an idea what's wrong there - as said, I'm only trying to get a single entity? Best Regards, rwh