2012-04-02 20 views
1

PatientsTelephoneCallsHistoryという2つのエンティティが1-mの関係にあります。データモデルは、以下の累積レコードのLINQ

enter image description here

ある enter image description here

クエリは以下の通りです

は、私が患者の記録場所を返したいサンプル電話データ enter image description here

です連絡先の結果はコールバックです。次の数件のレコードには必要です連絡先目的完成されました。基本的には、ユーザーにフォローアップの警告/通知を作成しようとしています。

私は、次のコード

query = query 
    .Where(m => !m.PatientsMasterItem 
      .PatientsTelephoneFollowupDetail.Any(l => l.Status == "1")); 

が出ている。しかし、それは(テストデータを参照してください)上記の例では動作しません。しかし、最後の記録にはフォローアップのための行動が必要です。

+0

二つの質問を下回っているlikeSomething何かを必要としています。ドメインモデルを表示できますか?クエリの初期値は何ですか? – ADIMO

+0

あなたのスクリーンショットはあなたの質問にどのように関係していますか? –

+0

このスクリーンショットは、1人の患者のサンプルデータを示しています。ステータス1は「連絡先の完了」を示し、 – user1213055

答えて

1

これはコンパイルされていません。これは単なるヒントです。あなたは

 var required = query.Where(DoesPatientNeedCallback); 

     public static bool DoesPatientNeedCallback(Patient p) 
     { 
       var last = p.PatientsMasterItem.PatientsTelephoneFollowupDetail.LastOrDefault(c => c.Status == 'Contact Required' || c.Status == 'Contact Purpose Completed); 
       return last != null && last.Status == 'Contact Required' 

     } 
0

のように完全なコードが

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Microsoft.LightSwitch; 
using Microsoft.LightSwitch.Security.Server; 

namespace LightSwitchApplication 
{ 
public partial class ApplicationDataService 
{ 

    partial void StatusCallBackRequired_PreprocessQuery(ref IQueryable<PatientsTelephoneFollowupDetail> query) 
    { 
     var required = query.Where(PatientNeedCallback); 

    } 

    public static bool PatientNeedCallback(PatientsTelephoneFollowupDetail p) 
    { 
     var last = p.PatientsMasterItem.PatientsTelephoneFollowupDetail.LastOrDefault(c => c.Status == "7" || c.Status == "1"); 
     return last != null && last.Status == "7"; 

    } 
}  


}