0

次の4つのテーブルがあるlinqステートメントを試みています

table: plan
id
planname

table: patient 
Fields
id, firstname, lastname, site_id

Table: site
id,
sitename

table: plan_patient
id
site_id
patient_id

table: plan_Exclusions
id
patient_id
plan_id
site_id

table: plan_schedule
id
patient_id
plan_id
site_id

計画に割り当てられていない、または計画から除外されていないすべての患者を引き戻したいと考えています。

患者が計画に割り当てられていないかどうかを決定するのは、患者が除外テーブルにあり、テーブルにスケジュールがなく、テーブルplan_scheduleに存在しないことですplan_patient

これはストアド プロシージャで簡単に実行できますが、結果を取得するためにストアド プロシージャを実行する必要がないように、これを構築しようとしています。

4

1 に答える 1

0

これは私が複合体のために複数のテーブルに手を差し伸べた方法です

var MyResults =
   from hc in context.hcTypes
   from hga in context.hgaToGmuTypes
   from hq in context.hqToQuota
   from qt in context.Types
   from dd in context.ddDraws
   from dh in context.dhDraws
   where hc.Year == dtYear
        && hc.Year == hga.Year
       && hc.code == hga.code
       && hc.Year == hq.Year
       && hc.code == hq.code
       && hq.Id == qt.Id
       && qt.PrefernceCode == "Y"
       && hga.Year == dtYear
       && hga.Code == "Z"
       && hc.code == dd.code
       && dd.Code == dh.Code
       && dh.Year == dtYear
       && dh.Code == "Z" 
       && dh.Left == "P"
select new MyClass { Id = hc.Id, Huntcode = hc.Huntcode, GMU = hga.GMUTypeCode }
 ;

あなたの場合、それは次のようになります:

var YourResults = 
    from pl in plan 
    from pa in patient 
    from s = site 
    from plan_patient 
    from plan_Exclusions 

    with the Where statements linking the data 
    and the Select pulling what you want
于 2013-02-14T19:53:44.827 に答える