3
votes

I am trying to create a method in my DomainService to return a list of strings. The reason why I am doing this is because I don't want to return whole entities of information. I can create a method to return a single string, as follows:

    public string GetDestinations()
    {
        return "Hello world";
    }

This works ok from the client via a InvokeOperation<string> call. However, when I turn the DomainService method into Ienumerable, as follows;

    public IEnumerable<string> GetDestinations()
    {
        List<String> h = new List<string>();
        h.Add("HELLO");
        h.Add("WORLD");

        return h;
    }

And then obviously use an InvokeOperation<IEnumerable<string>> call I get a compiler error:

Type 'String' is not a valid entity type. Entity types cannot be a primitive type or a simple type like string or Guid.

Huh? This doesn't make sense given that I can return a single string. How do I return a list of strings from my DomainService?

2
Interesting at first I didn't have trouble with InvokeOperation<IEnumerable<string>> I used opresult.Value but then I started getting this error createriaclientfilestask failed ! .Even I tried @Alessandro's offer it seems same.Davut Gürbüz
Ohh I realized that the error I got was "createriaclientfilestask fail" depending Out Of Memory (Its 8GB but 3GB is free). Then I could built it after make my memory free.I did as you did web side returns IEnumerable<string> and on the Bus side I use it as invokop.Value.toList<string>(). We use SL4 and Ria Services V1 SP 2.Davut Gürbüz

2 Answers

6
votes

Try returning an array of strings and marking the method as an InvokeOperation.

[Invoke]
public string[] GetDestinations()
{
...
}
2
votes

By convention the method that returns IEnumerable counted as Query method. Query method can return only collection of entities. Add Invoke attribute to your method.