这是我工作的LINQ to dataset查询。我添加了第四个表,我想在查询中添加一个NOT IN类型过滤器,其中query1.dedpk NOT IN deduct.dedpk。不知道怎么做。
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"),
};
由于
答案 0 :(得分: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"),
};