2011-07-20 3 views
0

WCF RIAサービス経由でLINQを使用して2つのクエリを結合しようとしています。複数のLoadOperationsからクエリする方法

LoadOperationから作成された2つのリストを照会しようとするたびに、決して結果が得られません。ここで

は私のコードです:

 LoadOperation<BTSLead_vw> lo = bictx.Load<BTSLead_vw>(bictx.GetBTSAttendedQuery().Take(2000)); 
     List<BTSLead_vw> btsattended = lo.Entities.ToList<BTSLead_vw>(); 
     LoadOperation<SyStudentApps> c2000lo = c2000ctx.Load<SyStudentApps>(c2000ctx.GetSyStudentAppsQuery().Take(2000)); 
     List<SyStudentApps> c2000apps = c2000lo.Entities.ToList<SyStudentApps>(); 

     var query = from bts in btsattended 
        join apps in c2000apps on bts.SystemLeadID equals apps.SyStudentID 
        select new BTSMasterQuery 
        { 
         SyStudentID = apps.SyStudentID, 
         EventDate = (DateTime)bts.EventDate, 
         StartTime = (DateTime)bts.StartTime, 
         SchoolStatus = apps.SchoolStatus, 
         LeadCat = apps.LeadCat, 
         StuNum = apps.StuNum, 
         AppRecDate = Convert.ToDateTime("11/01/2001")/*(from enroll in c2000ctx.GetAdEnrollsQuery() 
             where enroll.SyStudentID == apps.SyStudentID 
             select enroll.AppRecDate).First()*/, 
         TourAttended = (
             bts.InterestTitle == "Recording Arts Converted Group" ? "Recording Arts" : 
             bts.InterestTitle == "Digital Arts Converted Group" ? "Digital Arts and Design" : 
             bts.InterestTitle == "Unclear Converted Group" ? "Unknown" : 
             bts.InterestTitle == "Film and Video Converted Group" ? "Film and Video" : 
             bts.InterestTitle == "Show Production Converted Group" ? "Show Production" : 
             bts.InterestTitle == "Gaming Converted Group" ? "Gaming" : 
             bts.InterestTitle == "Entertainment Business Converted Group" ? "Entertainment Business" : bts.InterestTitle), 
         Gender = apps.Gender, 
         Ethnicity = apps.Ethnicity 
        }; 
     this.radGridView1.ItemsSource = query; 

私は検索の数十を行っている、と私はそれがリストをGridViewのにバインドされる前にロードされていないデータに関係していることを理解し、しかし、私はクエリーの一部として2つのLoadOperationsで回避する方法が不明です。

おかげで、

ギャレット

答えて

1

あなたはロード完了イベントに応答して、負荷運転オブジェクト(LOやc2000lo)のエンティティのメンバーを使用していない非同期ロードを設定されていませんが、。

データがサーバーから送られる前に照会することはできません。あなたの例では、lo.Entitiesとc2000lo.Entitiesの結果を結合する前に、2回のロード操作が完了するまで待たなければなりません。しかし、それを行う悪い方法です...

これを単純化する通常の方法は、サーバー上で結合と抽出を行い、必要な実際の結果だけの適切なデータ型のIEnumerableを返すことです。 Silverlightでは、常にクライアントに転送されるデータの量を最小限に抑えたいと考えています。

LoadOperation<Customer> loadOp = this._customerContext.Load(this._customerContext.GetCustomersQuery()); 
    CustomerGrid.ItemsSource = loadOp.Entities; 
:ロードが完了する前に Entitiesは、データが同じようにロードされたときにバインディングを通知します単なるコンテナであるよう

あなたは(あなたのloのように)ロード操作を取り、そのEntitiesメンバーに結合することができ、

関連する問題