linq写连接查询

下面用linq写很顺手。

var ts_codes_QueShao =
            (
                from ts_code in ts_codes_All
                join dr in dt.AsEnumerable() on ts_code equals dr["ts_code"].ToString() into tt
                from dr in tt.DefaultIfEmpty()
                select new
                {
                    ts_code,
                    ts_code_my = dr == null ? "" : dr["ts_code"].ToString()
                }
            )
            .Where(o => string.IsNullOrEmpty(o.ts_code_my))
            .Select(o => o.ts_code)
            .ToList();

之前没怎么用join。

这里记录一下。

 

posted @ 2020-12-24 14:27  法宝  阅读(99)  评论(0编辑  收藏  举报