Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot access EntityObject type via RIA services
    text
    copied!<p>My Entity Framework model is generated from SQL Server database. Since I need to access database from Silverlight, I generated a DomainService for RIAServices against the EF model. <code>Product</code> is one of the autogenerated <code>EntityObject</code> corresponding to the table <code>Product</code>. I am attempting to pass the custom class <code>CompositeData</code> across to the Silverlight client as shown. The problem is that <code>CurrentProduct</code> field is not accessible in the client but the other string/int fields are accessible. How can make <code>CurrentProduct</code> accessible from client?</p> <pre><code>public class CompositeData { [Key] public Guid PKey { get; set; } public string CompositeName { get; set; } public string Identity { get; set; } public Product CurrentProduct { get; set; } //Product is an auto-generated EntityObject class public CompositeData() { PKey = Guid.NewGuid(); } } </code></pre> <p>Following is the Domain Service method:</p> <pre><code>[EnableClientAccess()] public class LocalDomainService : DomainService { public IEnumerable&lt;CompositeData&gt; GetData() { List&lt;CompositeData&gt; listData = new List&lt;CompositeData&gt;(); //... return listData; } } </code></pre> <p>From the Silverlight client, </p> <pre><code> domService.Load(domService.GetDataQuery(), GetDataCompleted, null); private void GetDataCompleted(LoadOperation&lt;CompositeData&gt; compData) { foreach(CompositeData cdItem in compData.Entities) { // cdItem.CompositeName is accessible // cdItem.CurrentProduct is not accessible! } } </code></pre> <p>EDIT: <code>Product</code> class is autogenerated in Model1.Designer.cs </p> <pre><code> [EdmEntityTypeAttribute(NamespaceName="MyDBModel", Name="Product")] [Serializable()] [DataContractAttribute(IsReference=true)] public partial class Product : EntityObject { //.. } </code></pre> <p>It gets generated in the client project also (in SilverlightProject.g.cs)</p> <pre><code> /// &lt;summary&gt; /// The 'Product' entity class. /// &lt;/summary&gt; [DataContract(Namespace="http://schemas.datacontract.org/2004/07/SilverlightProject")] public sealed partial class Product : Entity { //.. } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload