Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight Domain Service - How to have a single [Invoke] operation
    primarykey
    data
    text
    <p>I have a custom domain service with a single [Invoke] operation that returns a List of User objects. </p> <p>In order to get it to compile, I have to stump out the User object in a property (highlighted as 'DONOTUSE' below) or method outside of the [Invoke] operation otherwise I am met with the following compile time error:</p> <blockquote> <p>Operation named 'GetUsers' does not conform to the required signature. Return types must be an entity or complex type, a collection of entities or complex types, or one of the predefined serializable types.</p> </blockquote> <p>Once I stump out the property it compiles and executes as intended, but the hack annoys the heck out of me.</p> <p>I do <strong>not</strong> wish to use the [Query] attribute so please do not suggest that I do. I say this because if I do switch to [Query] it compiles fine, however, I do not want to deal with the EntityQuery result set or its deferred execution.</p> <p>Due to the way I have the designed the architecture, the needs of the use case in this example and MSDN documentation, [Invoke] is the most appropriate means.</p> <pre><code>[EnableClientAccess()] public class UserDomainService : DomainService { private IUserService userService; public UserDomainService(IUserService service) { userService = service; } [Invoke, RequiresAuthentication] public List&lt;User&gt; GetUsers() { return userService.GetUsers(); } //HOW CAN I REMOVE THE FOLLOWING AND STILL COMPILE? public User DONOTUSE() { return null; } } </code></pre> <p>I'll leave you with this... I have another project that has custom DomainServices with single [Invoke] operations and <em>it</em> compiles fine. I cannot, for the life of me, figure out why one would compile over the other.</p> <p><strong>UPDATE</strong></p> <p>See comments in the selected answer below.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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