2015-06-01 300 views
0

我需要將npgsql查詢轉換爲Linq查詢。 Npgsql的樣子:Linq,日期比較

p.cmd = new NpgsqlCommand("select distinct min(h_dt::date) from w_h " + 
            "inner join us on h_us_id = us_id " + 
            "where cat_id != '' and h_dt::date not in (select distinct period_date from m_v " + 
            "where mv_id = 1)", conn); 

我嘗試轉換:

var q = (from t in context.w_h 
     join t1 in context.us 
     on t.h_us_id equals t1.us_id 
     where t1.cat_id != "" 
     select t.h_dt) 
     .Min(); 

我需要幫助的增加相比,這部分:不

和h_dt ::日期(選擇不同period_date from m_v)

h_dt :: date - return for date in forma牛逼YYYY-MM-DD

回答

1

有另一個集合持有這些結果:

q.Where(i=> ! v.Contains(i)); 

// pseudocode ! write your selection here: 
var v = select distinct period_date from m_v 

,然後簡單地用含有比較