C# Silverlight RIA 服务 - Context.Load() 不支持加载多个查询?

发布于 2024-08-05 10:52:59 字数 1953 浏览 3 评论 0原文

场景

目前我有 ac# silverlight 业务应用程序。该应用程序托管在 Asp.net 中,使用 ADO.Net 实体框架和域服务类来读取/写入我的 sql server 数据库。

设置

客户端 UI

在我的 silverlight 客户端界面中,我有一个自动完成框,它使用查询来获取与搜索相关的项目列表。查询位于我的域服务类中,如下所示:

public IQueryable<Status> GetStatus()
        {
            var q = (from job in Context.Job
                     select job.Status).Distinct()
                    .Select(deliveryState => new Status
                    {
                        DeliveryState = deliveryState,
                        Count = Context.Job.Count
                            (job => job.Status.Trim() == deliveryState.Trim())
                    });
            q = q.Where(job => job.DeliveryState != null);
            return q;
        }

代码隐藏

然后,在 silverlight 客户端接口 xaml 页面的代码隐藏中,我使用以下代码在构造函数中加载查询:

var context = dds.DomainContext as InmZenDomainContext;
            statusFilterBox.ItemsSource = context.Status;
            context.Load(context.GetStatusQuery(), (lo) =>
            {
                //just to show you how to load..  
                //new  ErrorWindow("Loaded.." + lo.Entities.Count()).Show(); 
            }, null);

问题

我遇到的问题是现在发生的情况如果我向客户端界面添加另一个自动完成框,以及另一个 Get 查询来执行不同类型的搜索:

public IQueryable<ShortCode> GetShortCode()
        {
            var q = (from job in Context.Job
                     select job.ShortCode).Distinct()
                    .Select(name => new ShortCode
                    {
                        Name = name,
                        Count = Context.Job.Count
                            (job => job.ShortCode.Trim() == name.Trim())
                    });
            q = q.Where(job => job.Name != null);
            return q;
        }

由于“Context.Load()”函数不支持加载多个查询,因此出现了问题。另外,如果我尝试声明单独的“Context.Load()” - 只有其中一个有效......

我该如何解决这个问题!?!

The Scenario

Currently I have a c# silverlight business application. The application is hosted in Asp.net using the ADO.Net entity framework and a domain service class to read/write to/from my sql server database.

The Setup

Client UI

In my silverlight client interface I have an autocomplete box which uses a query to get a list of items relating to the search. The query is in my domain service class and looks as follows:

public IQueryable<Status> GetStatus()
        {
            var q = (from job in Context.Job
                     select job.Status).Distinct()
                    .Select(deliveryState => new Status
                    {
                        DeliveryState = deliveryState,
                        Count = Context.Job.Count
                            (job => job.Status.Trim() == deliveryState.Trim())
                    });
            q = q.Where(job => job.DeliveryState != null);
            return q;
        }

Code Behind

Then in my code behind for the silverlight client interface xaml page, I load the query in the contructor using the following code:

var context = dds.DomainContext as InmZenDomainContext;
            statusFilterBox.ItemsSource = context.Status;
            context.Load(context.GetStatusQuery(), (lo) =>
            {
                //just to show you how to load..  
                //new  ErrorWindow("Loaded.." + lo.Entities.Count()).Show(); 
            }, null);

The Issue

The issue I have is what happens now if I add another autocomplete box to my client interface, and another Get query to perform a different type of search:

public IQueryable<ShortCode> GetShortCode()
        {
            var q = (from job in Context.Job
                     select job.ShortCode).Distinct()
                    .Select(name => new ShortCode
                    {
                        Name = name,
                        Count = Context.Job.Count
                            (job => job.ShortCode.Trim() == name.Trim())
                    });
            q = q.Where(job => job.Name != null);
            return q;
        }

The issue arises due to the fact that the "Context.Load()" function does not support loading multiple queries. Also If I try to declare to separate "Context.Load()" - Only one of them works........

How can I get around this!?!

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

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

发布评论

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

评论(2

眼眸印温柔 2024-08-12 10:52:59

这是对你问题的间接回答,所以要么接受要么放弃。

我在一个屏幕上有多个 AutoCompleteBox,但我没有使用 DDS。很久以前,当我不断遇到问题时,我就放弃了DDS。我不喜欢 dds 的主要一点是,太多的逻辑都在视图中。

我所做的是将 ACB 直接绑定到实体,并使用自定义过滤器来执行复杂的搜索。它搜索的列表是我使用 get 命令填充的实体列表,

public EntityList<Person> Person
        {
            get { return _DomainContext.Persons; }
        }

我可以更详细地介绍,但如果您锁定使用 DDS,那么我将保留它。

This is kind of an indirect answer to you question so take it or leave it.

I have multiple AutoCompleteBoxes on one screen but I am not using a DDS. I gave up the DDS a long time ago when I kept running into problems. The main thing that I dont like about the dds is that so much of the logic is in the view.

What I do is bind my ACB directly to the entity and use a custom filter to do my complex searches. The list that it searches is an entity list that I populate using the get command

public EntityList<Person> Person
        {
            get { return _DomainContext.Persons; }
        }

I could go into more detail but if you are lock into using the DDS then I will leave it at that.

青巷忧颜 2024-08-12 10:52:59

每个负载有一种实体类型,但同时运行多个负载应该不会有任何问题。您是否安装了 Fiddler 来观察网络上实际发生的情况?

There is one entity type per load, but there shouldn't be any problem having multiple loads running at the same time. Do you have Fiddler installed to watch what is actually going across the wire?

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