1

I have a Silverlight application in which I call my WCF service to get data from the database. If there is a small number of records then it's working fine, but if there are many records then it throws a System.OutOfMemory exception.

I have traced it in a WCF error log file. Are there any ways to compress the data which is coming from WCF to the Silverlight application?

4

3 回答 3

0

在您的服务 Web 配置中,在服务行为和端点行为中添加此项。然后它可以传输高达 2 GB 的数据。

 <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
于 2012-11-05T06:28:17.887 回答
0

U can use IIS dynamic compression for WCF messages. Read next threads/articles:

Enabling dynamic compression

GZip compression with WCF hosted on IIS7

于 2012-11-03T12:33:29.893 回答
0

一次传输 500,000(半百万)条记录对于您的系统来说太大了,无法处理。我还要说您的用户无法处理太多。

您应该将其分解为数据页,并且一次只返回几页。Silverlight/WCF (RIAServices) DomainDataService 可以为您处理所有这些:

<riaControls:DomainDataSource QueryName="GetResults"
                              LoadSize="200"
                              PageSize="100"
                              AutoLoad="True"/>

您将分页器控件添加到页面以在用户控制下的数据页面中移动。

这使您的应用程序更具响应性,因为您每次只返回少量数据。一次性返回 500,000 条记录也很可能导致连接速度较慢的人超时。

我还建议您考虑过滤数据,以便只返回用户感兴趣的数据。

于 2012-11-05T10:06:42.010 回答