簡體   English   中英

Linq,日期比較

[英]Linq, date comparison

我需要將npgsql查詢轉換為Linq查詢。 Npgsql看起來像:

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 :: date不在(從m_v中選擇不同的period_date)

h_dt :: date-返回日期,格式為yyyy-MM-dd

有另一個集合來保存這些結果:

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

然后簡單地與包含進行比較:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM