/ / SilverlightページングWebサービスの結果 - Webサービス、Silverlight

SilverlightページングWebサービスの結果 - Webサービス、Silverlight

私たちにはSilverlightアプリケーションがあります。Webサービスを使用してSQL Serverからデータベース行を取得します。これらはページされたコントロールの画面に表示されます。ただし、テーブル全体が必要で、数千の行で構成されています。顧客システムでは、約1500行以上を要求すると、HttpRequestTimedOutWithoutDetailが取得されます。私たちの開発システムでは、これが起こる前に約50万行が必要です。

明らかに、私たちがしなければならないことは、結果をビットごとにシルバーライトに戻します。しかし、私はこれを行う方法を知っていません。誰も助言するか、または原理と方法を明確に説明するいくつかのWebページを指摘することができますか(私はちょっと単純です!)

Webサービスのコードは次のとおりです。

    public IQueryable<Referral> GetReferrals()
{
/*
* In the customer"s environments it seems that any more than around 1500 referrals will break the system: they will fail to load.
* In the dev environment is takes around 500,000 so it seems to be timeout related.
*
* The code below was an attempt to restrict the number, only returning referrals above a certain size and within a certain age.
* It seems the customer is more interested in the smaller referrals though since they are more likely to be added to existing
* substations so if this method is re-instated, we should be using "<" instead of ">"
*
int mdToBeMet = int.Parse(ConfigurationManager.AppSettings["ReferralMDToBeMet"]);
DateTime minusNYears = DateTime.Today.AddYears(int.Parse(ConfigurationManager.AppSettings["ReferralTargetDate"]) * -1);
int maxReferralsCount = int.Parse(ConfigurationManager.AppSettings["ReferralMaxRecordCount"]);
if (mdToBeMet != 0 && maxReferralsCount != 0)
{
return this.ObjectContext.Referrals.Where(x => x.MD_to_be_Met > mdToBeMet && x.Target_Date > minusNYears).OrderByDescending(y => y.Target_Date).Take(maxReferralsCount);
}
*/

/*
* This is the 2nd attempt: the customer is mainly interested in referrals that have an allocated substation
*/
bool allocatedReferralsOnly = bool.Parse(ConfigurationManager.AppSettings["ReferralAllocatedOnly"]);
int maxReferralsCount = int.Parse(ConfigurationManager.AppSettings["ReferralMaxRecordCount"]);

if (allocatedReferralsOnly)
{
var referrals = this.ObjectContext.Referrals.Where(x => x.Sub_no != "").OrderByDescending(y => y.Target_Date).Take(maxReferralsCount);
return referrals;
}
else
{

/*
* Ideally, we should just page the referrals here and return to retrieving all of them, bit by bit.
*/
var referrals = this.ObjectContext.Referrals;
return referrals;
}
}

ご意見ありがとうございました。

回答:

回答№1は0

私が与えたコメントを拡大する例...

/// <summary>
/// Returns a page of Referrels
/// pageNumber is 0-index based
/// </summary>
public IQueryable<Referrel> GetReferrals(int pageNumber)
{
var pageSize = 100;
return ObjectContext.Referrals.Skip(pageNumber*pageSize).Take(pageSize);
}

明らかに、あなたは pageSize もし望むのであれば、このメソッドの外側のどこかで定数として定義することもできます。