开发者

silverlight 4 ria wcf- return multiple lists of complex objects

I need some help figuring out the right pattern for this situation:

I have a view with 5 cascading comboboxes. When you select a 开发者_如何学Govalue from the first combobox, a service call is made to get the results for the next combobox, which is then enabled. The user makes the next selection and the process continues. This works fine. Next I'm given the case where the user returns to this view with the data already selcted, and the appropriate data already filled in each combobox.

I don't want to make all the calls over one by one to get the data, this seems wastefull. Instead I'd like to make one call and return all the data at once. Using RIA WCF Services, what is the best way to achieve this?

Here is what I've tried, but its not working as I hoped.

A) I made a class on the server side, then added a method to the service returning this type

public partial class SelectionValues
{
    public List<Series> SeriesList {get;set;}
    public List<BaseModel> BaseModelList {get;set;}
    public List<FullModel> FullModelList {get;set;}
    public List<Program> ProgramList {get;set;}
    public List<ExtendedWarranty> ExtendedWarrantyList{get;set;}
}

[in the service]
/// <summary>
/// This function does nothing, just exposes the SelectionValues type
/// </summary>
/// <returns></returns>
public IQueryable<SelectionValues> getUnitSelectionValues()
{
    throw new NotImplementedException();
}

Result: None of the lists generated on the client side.

B) So I added .Shared.cs to the class file, so the class would be the same on the client side. Then I wrote the Service method to return the data I need. The code works, but the data in the lists in the SelectionValues object don't come across to the client side.

[Invoke]
public SelectionValues GetValuesForExistingUnit( ..... )
{
    SelectionValues result = new SelectionValues ();
    ...
    return result
}

Is there a way to return multiple lists of complex objects at once, or am I doomed to make multiple calls chained together?


For what I know RIA Services only return Entities from your DomainService. I have done something similar where I needed to return a struct of my own. I solved that scenario by creating a simple WCF service that returns my new object with every list I want inside of it.
Keep in mind those objects are not in your Entityset so don't try to modify them and send them back to the server via a RIA Service.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜