silverlight 4 ria wcf-返回复杂对象的多个列表

发布于 2024-11-27 11:54:57 字数 1370 浏览 0 评论 0原文

我需要一些帮助来找出适合这种情况的正确模式:

我有一个包含 5 个级联组合框的视图。当您从第一个组合框中选择一个值时,将进行服务调用以获取下一个组合框的结果,然后启用该组合框。用户做出下一个选择并且该过程继续。这很好用。接下来,我给出的情况是,用户返回到此视图,并且已选择数据,并且每个组合框中已填充适当的数据。

我不想一一进行所有调用来获取数据,这似乎很浪费。相反,我想拨打一个电话并立即返回所有数据。 使用 RIA WCF 服务,实现此目的的最佳方法是什么?

这是我尝试过的方法,但它没有按我希望的方式工作。

A) 我在服务器端创建了一个类,然后向返回此类型的服务添加了一个方法

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();
}

结果:客户端上没有生成任何列表。

B) 所以我将 .Shared.cs 添加到类文件,因此类在客户端是相同的。然后我编写了Service方法来返回我需要的数据。该代码有效,但 SelectionValues 对象中的列表中的数据不会到达客户端。

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

有没有办法一次返回多个复杂对象列表,或者我注定要将多个调用链接在一起?

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

I have a view with 5 cascading comboboxes. When you select a value 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谷夏 2024-12-04 11:54:57

据我所知,RIA 服务仅从您的 DomainService 返回实体。我做了类似的事情,我需要返回自己的结构。我通过创建一个简单的 WCF 服务解决了这个场景,该服务返回我的新对象以及我想要的每个列表。
请记住,这些对象不在您的实体集中,因此不要尝试修改它们并通过 RIA 服务将它们发送回服务器。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文