简体   繁体   English

Silverlight中的部分实体加载和管理/ WCF RIA

[英]partial entity loading and management in silverlight / wcf ria

I have a Silverlight 4 app which pulls entities down from a database using WCF RIA services. 我有一个Silverlight 4应用程序,该应用程序使用WCF RIA服务从数据库中提取实体。 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. 我的问题是由于此数据的大小,加载时间不可接受,并且可能接近RIA服务的默认超时。

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. 我想以某种方式将对象部分加载到本地数据上下文中,以便获得ID,名称等,但没有二进制数据。 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. 在写这个问题时(我多久发生一次!),我想到的另一种方法是,我可以将二进制数据移动到与原始记录1:1相连的单独的数据库表中,这将使我能够利用RIA的延迟加载该二进制数据。

again.. comments welcome! 再次..评论欢迎! Thanks. 谢谢。

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. 为您的项目快速列表创建一个单独的WCF RIA服务,并使用POCO(普通的旧clr对象)发送所需数据的摘要。 Then, when you're ready for the big guy, you can download one at a time triggered from data from your POCO. 然后,当您准备好大手笔时,可以一次从POCO的数据触发下载一个。

Brad Abrams and Nikhil Kothari have talked about using POCO for a while. 布拉德·艾布拉姆斯Brad Abrams)尼基尔·科塔里Nikhil Kothari)谈论使用POCO已有一段时间。 Look at their MIX speeches for more information. 请查看他们的MIX演讲以获取更多信息。

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

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

Good luck! 祝好运!

ps Nikhil's BookClub app does this a lot. ps Nikhil的BookClub应用程序执行了很多操作。 If you need to see a real application doing this, download his app: http://www.nikhilk.net/Content/Presentations/MIX10/BookClub.zip 如果您需要查看执行此操作的真实应用程序,请下载他的应用程序: http : //www.nikhilk.net/Content/Presentations/MIX10/BookClub.zip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM