R – WCF RIA Services – Returning Entity from Invoke Operation

netsilverlight-3.0wcf-ria-services

I was happily using RIA Services JULY 09 version and using a ServiceOperation for a method which takes some parameters and returns Entity.

[ServiceOperation]
public Entity TestMethod(string param1, string param2, bool param3)
{
// do something here
}

But as soon as i UPGRADED to WCF RIA services, I had to change [ServiceOperation] to [Invoke], but now I am getting a compilation error that Entity can not be returned for an Invoke Operation.
I searched here and there and found out that for VS2008 it does not work but for VS 2010 it still works.
I need to know if there's a workaround to do this for VS2008. I don't want this method to have deferred execution like query methods.

Best Answer

No, there isn't a workaround for 2008.

Eventually the VS2010/.NET 4 version of RIA Services will be RTM'd... so I'd suggest using that if you can deploy on top of .net 4.

If you have to stay on 3.5, then a query method is your only route. As a workaround, you can new up a DomainContext, issue a Load call, use the Entities result of the LoadOperation, and then simply discard the DomainContext... in other words you don't need to use the EntitySet/accumulation model if you don't want to for your particular scenario.

Related Topic