简体   繁体   English

如何加载具有大量记录的silverlight实体?

[英]How to load silverlight Entities with a large number of records?

I have a big table in my SQL Server database with 38000 records! 我的SQL Server数据库中有一个包含38000条记录的大表! When loading this table in my Silverlight application, it shows 0 records loaded. 在我的Silverlight应用程序中加载此表时,它显示已加载0条记录。 When I load the same table with less records (1000 for example ) the entity is loaded with all records! 当我用较少的记录加载相同的表(例如1000)时,实体加载了所有记录!

Can anyone help me please? 有人可以帮我吗?

      loadhabitaion = this.friendsContext.Load(this.friendsContext.GetHyd_poliQuery());
      loadhabitaion.Completed += new EventHandler(loadhabitaion_Completed);
      void loadhabitaion_Completed(object sender, EventArgs e)

         {

        MessageBox.Show(loadhabitaion.Entities.Count().ToString());
          //it returns 0
         }

Change the configuration file and set the <dataContractSerializer maxItemsInObjectGraph="2147483647"/> as shown below. 更改配置文件并设置<dataContractSerializer maxItemsInObjectGraph="2147483647"/> ,如下所示。

This solved my issue and it will also solve yours. 这解决了我的问题,它也将解决你的问题。

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" />
              <!--Added the next line so silverlight could recieve large data chunks-->
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>

It has to do with the maximum amount of serialization. 它与最大量的序列化有关。 Check the Web.config file for this section 检查Web.config文件以获取此部分

<behaviors>
  <serviceBehaviors>
    <dataContractSerializer maxItemsInObjectGraph="1310720"/>

See http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.maxitemsinobjectgraph.aspx 请参阅http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.maxitemsinobjectgraph.aspx

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

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