I have a Silverlight app with Ria Service and EF. In my ViewModel i want to access a coleccion by navigating the entity relationship, in my service i have setup the query and i see that my collection is retrieved correctly, but in my Silverlight side in my ViewModel class it is lost. Anybody had come across with this issue?
The code in DomainService:
var retVal = (from e in ObjectContext.embarques.Include("Bultos")
where e.nro_embarque == nroEmbarque && e.nro_sub_embarque == nroSubembarque
select e).FirstOrDefault();
return retVal;
Above retVal have the desired result in Bultos, then in my ViewModel
EntityQuery<embarques> query = context.GetEmbarqueQuery(NroEmbarque, NroSubembarque);
LoadOperation<embarques> op = context.Load(query);
op.Completed += (sender, e) => {
if (!op.HasError) {
Embarque = op.Entities.FirstOrDefault();
if (null != Embarque) {
Bultos = new ObservableCollection<Bultos>(Embarque.Bultos);
}
}
};
}
Above Embarque.Bultos.Count = 0
The only peace i was missing here is to put [Include] attribute in embarquesMetadata class:
once included, everything like a charm