Note that there are some explanatory texts on larger screens.

plurals
  1. POAlternative to Using an Entity as a Parameter to an Invoke Method in WCF RIA Services
    text
    copied!<p>Howdy, ya'll! First question on StackOverflow! :-)</p> <p>So here's the scenario: We're working on a web app with Silverlight 4 and using WCF RIA Services 1.0 SP1 Beta for the web service. I have my entities in the Entity Framework Designer, but I'm using a slightly-modified ADO.NET C# POCO Entity Generator template to generate the classes.</p> <p>What I'd like to do is have a method inside a Domain Service with the following signature:</p> <pre><code>[EnableClientAccess] public class ResultService : DomainService { [Invoke] public SerializableResult CalculateResult(EntityOne e1, EntityTwo e2); } </code></pre> <p>I am returning both EntityOne and EntityTwo to the client through queries in other services, like so:</p> <pre><code>[EnableClientAccess] public class EntityOneService : DomainService { public IQueryable&lt;EntityOne&gt; GetEntityOnes(); } [EnableClientAccess] public class EntityOneService : DomainService { public IQueryable&lt;EntityTwo&gt; GetEntityTwos(); } </code></pre> <p>Those classes <em>are</em> successfully being generated in the Silverlight project. The SerializableResult does <em>not</em> have a key.</p> <p>When I try to compile, I get the following error: "Operation named 'CalculateResult' does not conform to the required signature. Parameter types must be an entity or complex type, a collection of complex types, or one of the predefined serializable types."</p> <p>In my research, the most helpful information I found were in the comments of <a href="http://jeffhandley.com/archive/2010/10/27/RiaServicesV1SP1Beta.aspx" rel="noreferrer">this post by Jeff Handley</a>.</p> <p>Of note, Peter asked in a comment:</p> <blockquote> <p>I get an 'does not conform to the required signature ...' compile error if my complex object has an [Key] Attribute. When I remove this attribute I can use the object as parameter for an Invoke operation.</p> </blockquote> <p>Jeff's response:</p> <blockquote> <p>This is by design. Complex objects cannot have Key properties. If you have a Key the class gets treated as an Entity.</p> </blockquote> <p>So it sounds as if any further efforts to try to get my method to work will be futile. However, I was wondering if anyone else has come across this problem, and what they did to solve it.</p> <p>Thanks very much!</p>
 

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