silverlight/wcf ria 中的部分实体加载和管理

发布于 2024-08-28 18:49:04 字数 421 浏览 1 评论 0原文

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

我的问题是由于该数据的大小,加载时间不可接受,并且可能接近默认超时RIA 服务。

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

任何有关如何实现这一目标的建议都将受到欢迎。

我在写这个问题时想到的另一种方法(这种情况多久发生一次?!)是我可以将二进制数据移动到一个单独的数据库表中,与原始记录 1:1 连接,这将允许我利用 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.

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.

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.

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.

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

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

发布评论

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

评论(1

懒的傷心 2024-09-04 18:49:04

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

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

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

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

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 只是服务器上的一个对象,如下所示:

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

祝您好运!

ps Nikhil 的 BookClub 应用程序经常这样做。如果您需要查看执行此操作的真实应用程序,请下载他的应用程序: http:// www.nikhilk.net/Content/Presentations/MIX10/BookClub.zip

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

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.

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

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

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

Good luck!

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

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