How to return List<int> from domain service

Hello guys im using WCF RIA Services i have domain services where i wrote this method

public List<int> GetActionIDs() 
    {
        return (from d in ObjectContext.actions select d.id).ToList();
    }

How i can get this List in client side? This does not works :

List<int> = db.GetActionIDs();

any suggestions?

Answers


First of all, you should read the RIA Services manual, because you don't realize that service calls in Silverlight are asynchronous.

In your case, you should

Add InvokeAttribute to your operation in the service:

[Invoke]
public List<int> GetActionIDs() 
{
    return (from d in ObjectContext.actions select d.id).ToList();
}

Then, all calls to DomainContext are asynchronous, so you get your results in the callback:

db.GetActionIDs(operation =>
                {
                  //TODO: check the operation object for errors or cancellation

                  var ids = operation.Value; // here's your value

                  //TODO: add the code that performs further actions
                }
                , null);

Need Your Help

Browser & OS as body class

javascript jquery

I would like to have the OS and the Browser in the body class. I need that for pixelperfect styling, because the fonts do not behave the same way in different OS / Browser configurations. After some

Right shift operator in java

java scjp

public class Operator {

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.