2012-03-17 21 views
0

我在我的SQL Server數據庫中有38000條記錄的大表!在我的Silverlight應用程序中加載此表時,它顯示加載了0條記錄。當我用較少的記錄加載同一個表(例如1000)時,實體將加載所有記錄!如何載入具有大量記錄的silverlight實體?

任何人都可以幫助我嗎?

 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 
     } 
+0

您需要顯示加載記錄的代碼。事件處理程序什麼也沒說。 – 2012-03-17 10:47:24

回答

1

它與最大的序列化量有關。 檢查web.config文件爲本條

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

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

+0

Thx爲您提供幫助! ihad已經試過這個但它沒有解決任何問題。 – 2012-03-17 22:02:49

+0

@MehdiKylar只是好奇,但你爲什麼要一次加載所有內容?帶Ria的Silverlight支持相對簡單的分頁方式。 – Silvermind 2012-03-18 10:55:48

+0

;我正在嘗試將deographique數據添加到我的圖層中,因此我必須立即加載它! – 2012-03-18 11:51:06

1

改變配置文件,並設置<dataContractSerializer maxItemsInObjectGraph="2147483647"/>,如下所示。

這解決了我的問題,它也將解決你的問題。

<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> 
相關問題