The My Entity Framework model is created from the SQL Server database. Since I need to access the database from Silverlight, I created a DomainService for RIAServices for the EF model. Product is one of the auto- EntityObject corresponding to the Product table. I am trying to pass a custom CompositeData class to a Silverlight client as shown. The problem is that the CurrentProduct field CurrentProduct not available in the client, but other string / int fields are available. How to make CurrentProduct available from the client?
public class CompositeData { [Key] public Guid PKey { get; set; } public string CompositeName { get; set; } public string Identity { get; set; } public Product CurrentProduct { get; set; }
The following is the Domain Service method:
[EnableClientAccess()] public class LocalDomainService : DomainService { public IEnumerable<CompositeData> GetData() { List<CompositeData> listData = new List<CompositeData>();
From Silverlight Client
domService.Load(domService.GetDataQuery(), GetDataCompleted, null); private void GetDataCompleted(LoadOperation<CompositeData> compData) { foreach(CompositeData cdItem in compData.Entities) {
EDIT: Product class is auto-generated in Model1.Designer.cs
[EdmEntityTypeAttribute(NamespaceName="MyDBModel", Name="Product")] [Serializable()] [DataContractAttribute(IsReference=true)] public partial class Product : EntityObject {
It is also generated in the client project (in SilverlightProject.g.cs)
/// <summary> /// The 'Product' entity class. /// </summary> [DataContract(Namespace="http://schemas.datacontract.org/2004/07/SilverlightProject")] public sealed partial class Product : Entity { //.. }
source share