Silverlight/wcf ria 中的部分实体加载和管理 [英] partial entity loading and management in silverlight / wcf ria

查看:25
本文介绍了Silverlight/wcf ria 中的部分实体加载和管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Silverlight 4 应用程序,它使用 WCF RIA 服务从数据库中提取实体.这些数据对象相当简单,只有几个字段,但其中一个字段包含任意大小的二进制数据.应用程序需要在用户登录后尽快访问这些数据,以显示在列表中,启用选择等.

I have a Silverlight 4 app which pulls entities down from a database using WCF RIA services. These data objects are fairly simple, just a few fields but one of those fields contains binary data of an arbitrarily size. The application needs access to this data basically asap after a user has logged in, to display in a list, enable selection etc.

我的问题是由于这些数据的大小,加载时间是不可接受的,可以接近 RIA 服务的默认超时.

My problem is because of the size of this data, the load times are not acceptable and can approach the default timeout of the RIA service.

我想以某种方式将对象部分加载到我的本地数据上下文中,以便我拥有 ID、名称等,但没有二进制数据.然后我可以在稍后(即实际需要时)填充我需要显示的那些对象的二进制字段.

I'd like to somehow partially load the objects into my local data context so that I have the IDs, names etc but not the binary data. I could then at a later point (ie when it's actually needed) populate the binary fields of those objects I need to display.

欢迎就如何实现这一目标提出任何建议.

Any suggestions on how to accomplish this would be welcome.

在写这个问题时我想到的另一种方法(这种情况多久发生一次?!)是我可以将二进制数据移动到一个单独的数据库表中,并以 1:1 的比例连接到原始记录,这将使我能够对该二进制数据使用 RIA 的延迟加载.

Another approach which has occurred to me whilst writing this question (how often does that happen?!) is that I could move the binary data into a seperate database table joined to the original record 1:1 which would allow me to make use of RIA's lazy loading on that binary data.

再次..欢迎评论!谢谢.

again.. comments welcome! Thanks.

推荐答案

不要更改您的数据库.更改您的送货方式.

Don't change your database. Change your delivery method.

为您的项目快速列表创建单独的 WCF RIA 服务,并使用 POCO(普通旧 clr 对象)发送您需要的数据摘要.然后,当您准备好迎接大人物时,您可以从 POCO 中的数据触发一次下载一个.

Create a seperate WCF RIA Service for your quick list of items and use a POCO (plain old clr object) to send down a summary of the data you need. Then, when you're ready for the big guy, you can download one at a time triggered from data from your POCO.

布拉德·艾布拉姆斯Nikhil Kothari 已经谈到使用 POCO 有一段时间了.查看他们的 MIX 演讲以了解更多信息.

Brad Abrams and Nikhil Kothari have talked about using POCO for a while. Look at their MIX speeches for more information.

为您的快速列表项创建新服务:

Create a new service for your quick list items:

public class QuickListService : LinqToEntitiesDomainService<MyEntities> 
{
    private IQueryable<QuickList> GetQuickList() 
    {
        return from t in ObjectContext.Table
              select new QuickList 
               {
                      ID = t.ID,
                     Title = t.Title
              };
    }
}

您的 POCO 只是服务器上的一个对象,如下所示:

Your POCO is simply an object on the server, like this:

public class QuickList
{
    public string Title;
    public long ID;
}

祝你好运!

附言Nikhil 的 BookClub 应用程序在这方面做了很多工作.如果您需要查看真正的应用程序,请下载他的应用程序:http://www.nikhilk.net/Content/Presentations/MIX10/BookClub.zip

p.s. Nikhil's BookClub app does this a lot. If you need to see a real application doing this, download his app: http://www.nikhilk.net/Content/Presentations/MIX10/BookClub.zip

这篇关于Silverlight/wcf ria 中的部分实体加载和管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆