I have a custom domain service with a single [Invoke] operation that returns a List of User objects.
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:
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.
Once I stump out the property it compiles and executes as intended, but the hack annoys the heck out of me.
I do not 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.
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.
[EnableClientAccess()]
public class UserDomainService : DomainService
{
private IUserService userService;
public UserDomainService(IUserService service)
{
userService = service;
}
[Invoke, RequiresAuthentication]
public List<User> GetUsers()
{
return userService.GetUsers();
}
//HOW CAN I REMOVE THE FOLLOWING AND STILL COMPILE?
public User DONOTUSE()
{
return null;
}
}
I'll leave you with this... I have another project that has custom DomainServices with single [Invoke] operations and it compiles fine. I cannot, for the life of me, figure out why one would compile over the other.
UPDATE
See comments in the selected answer below.
Have you tried exposing users like this ?
IQueryable<User> GetUsers() { throw new NotImplementedException(); }
That's a way of forcing the WCF Ria code generator to expose your entity client-side. You might try using shared code too, Class.shared.cs, look it up in the WCF Ria docs