Returning String[] from RIA Domain Service
I added a new method to my Domain Service today that has the signature:
public string[] GetSomething(string param1)
When I tried to compile this I got the following error, without any line or column information in Visual Studio’s Error List:
Type ‘String’ is not a valid entity type. Entity types cannot be a primitive type or a simple type like string or Guid.
After a bit of googling I found that returning a string is fine, but returning a string array is what’s causing the error. Lots of forum posts/blog entries recommend adding the ServiceOperation attribute to the method but I couldn’t find which namespace this was in.
I then found a breaking changed document for the PDC09 version of RIA services where it states that the ServiceOperation attribute was renamed to Invoke.
Simply adding the Invoke attribute to the domain service method enables a string array to be returned without any issues:
using System.ServiceModel.DomainServices.Server;
[Invoke]
public string[] GetSomething(string param1)