用于LINQ查询的可比较SQL?

时间:2016-11-25 19:58:01

标签: linq

是否有一个SQL查询可以提供与以下LINQ语句相同的结果?

DataTable dtAll1 = userData1.AsEnumerable()
    .Where(ra => !userData2.AsEnumerable()
    .Any(rb => rb.Field<string>("A") == ra.Field<string>("B")))
    .CopyToDataTable();

1 个答案:

答案 0 :(得分:0)

SELECT
    *
  FROM
    userData1 AS ra
  WHERE
    NOT EXISTS (SELECT * FROM userData2 AS rb WHERE ra.B = rb.A)

(从EXISTS更新为NOT EXISTS。)