简体   繁体   中英

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

I have a big table in my SQL Server database with 38000 records! When loading this table in my Silverlight application, it shows 0 records loaded. When I load the same table with less records (1000 for example ) the entity is loaded with all records!

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.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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