RIA 服务:服务器进程返回多个实体,但客户端显示 1 个重复实体

发布于 2024-09-24 01:46:45 字数 1229 浏览 0 评论 0原文

我遇到了 RIA 服务从服务器返回 3 个实体的问题(我在服务器进程上调试时进行了验证,并通过 Fiddler 验证了该服务正在返回 3 个实体。

我正在使用 MVVM,因此我调用 Load在客户端使用我从 Shawn Wildermuth 示例借用的辅助函数: 代码如下:

    // Generic query handling
     protected void PerformQuery<T>(DomainContext dc, string name, EntityQuery<T> qry, EventHandler<EntityResultsArgs<T>> evt) where T : Entity
    {
        dc.Load<T>(qry,(r) =>
        {
            if (evt != null)
            {
                try
                {
                    if (r.HasError)
                    {
                        evt(this, new EntityResultsArgs<T>(r.Error));
                    }
                    else if (r.Entities.Count() > 0)
                    {
                        evt(this, new EntityResultsArgs<T>(r.Entities));
                    }
                }
                catch (Exception ex)
                {
                    evt(this, new EntityResultsArgs<T>(ex));
                }
            }
        }, null);
    }

EntityResultsArgs 是一个简单的类,它公开一个异常属性(称为 Error)和一个 Results 属性(如果有结果,则包含结果)

。我们使用 AutoMapper 将结果映射到我们公开的域类的服务器,并且这个特定的服务调用返回

我缺少什么(或者还有什么可以帮助别人解决这个问题)

谢谢!

I am running into an issue where RIA Services returns 3 entities from the server (I have verified while debugging on the server process, and have verified via Fiddler that the service is in face returning 3 entities.

I am using MVVM so I am calling Load on the client side using a helper function that I borrowed from a Shawn Wildermuth sample: Here's that code:

    // Generic query handling
     protected void PerformQuery<T>(DomainContext dc, string name, EntityQuery<T> qry, EventHandler<EntityResultsArgs<T>> evt) where T : Entity
    {
        dc.Load<T>(qry,(r) =>
        {
            if (evt != null)
            {
                try
                {
                    if (r.HasError)
                    {
                        evt(this, new EntityResultsArgs<T>(r.Error));
                    }
                    else if (r.Entities.Count() > 0)
                    {
                        evt(this, new EntityResultsArgs<T>(r.Entities));
                    }
                }
                catch (Exception ex)
                {
                    evt(this, new EntityResultsArgs<T>(ex));
                }
            }
        }, null);
    }

EntityResultsArgs is a simple class that exposes an exception property (called Error) and a Results property (containing the results if we got any).

On the server we are mapping the result using AutoMapper to our exposed Domain Classes and this particular service call returns IEnumerable.

What am I missing (or what more would help someone figure this out).

Thanks!

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

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

发布评论

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

评论(1

一身骄傲 2024-10-01 01:46:45

是的,现在问题已经确定了。我从服务中检索了 3 个实体,所有实体的 Id(又名“[Key]”值)均为 0。

Yep, the problem is now confirmed. I was retrieving 3 entities back from the service all with an Id (aka the "[Key]" value) of 0.

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