0

这是我正在使用的 LINQ 到数据集查询。我添加了第四个表,我想在 query1.dedpk NOT IN deduct.dedpk 的查询中添加一个 NOT IN 类型的过滤器。不知道该怎么做。

  var main = dsTemp.Tables["Maindata"].AsEnumerable();
  var pg = dsTemp.Tables["pgto"].AsEnumerable();
  var py = dsTemp.Tables["pyto"].AsEnumerable();
  var deduct = dsTemp.Tables["Deduct"].AsEnumerable();

  var query1 = from mainrow in main
      join pgrow in pg on mainrow.Field<string>("pgpk") equals pgrow.Field<string>("pgpk")
      join pyrow in py on mainrow.Field<string>("pypk") equals pyrow.Field<string>("pypk")
      into griddata 
      select new
       {
       lastname = mainrow.Field<string>("lastname"),
       firstname = mainrow.Field<string>("firstname"),
 dedpk = mainrow.Field<string>("dedpk"),
        };

谢谢

4

1 回答 1

0
 var query1 = from mainrow in main
      join pgrow in pg on mainrow.Field<string>("pgpk") equals pgrow.Field<string>("pgpk")
      join pyrow in py on mainrow.Field<string>("pypk") equals pyrow.Field<string>("pypk")
      into griddata 
      where 
         !deduct.Any(x => x.Field<string>("dedpk") == mainrow.Field<string>("dedpk"))
      select new
      {
         lastname = mainrow.Field<string>("lastname"),
         firstname = mainrow.Field<string>("firstname"),
         dedpk = mainrow.Field<string>("dedpk"),
      };
于 2013-05-07T21:54:18.810 回答