0

我正在使用以下 LINQ 查询从数据表中获取数据

 var callBetweenNodesDetail = from r in dtRowCallBetweenNodes.AsEnumerable()
                                       where ((r.Field<string>("F1") == VerSelected1) && (r.Field<string>("F2") == VerSelected2))
                                       select r;

现在我想加入另一个包含两个字段“名称”和“F2”的数据表 dtRowFile,其中字段“F2”将与数据表 dtRowCallBetweenNodes 中的“F10”匹配以在结果集中获取“名称”

4

2 回答 2

1

这有帮助吗:

var ret = from p in Table1.AsEnumerable()
      join q in Table2.AsEnumerable() on p.Field<int>("ID") equals q.Field<int>("ID") into UP
      from q in UP.DefaultIfEmpty()
      select new
      {
          ID = p.Field<int>("ID"),
          Type = p.Field<string>("Type"),
          Part = q.Field<int>("Part"),
          Quantity = q.Field<int>("Quantity")
      };
于 2013-02-08T11:29:46.593 回答
0
var rowFileNames = from   r1 in dtRowCallBetweenNodes.AsEnumerable()
                   join   r2 in dtRowFile.AsEnumerable()
                   on     r1.Field<string>("F10") equals r2.Field<string>("F2")
                   where  r1.Field<string>("F1") == VerSelected1 
                   &&     r1.Field<string>("F2") == VerSelected2
                   select r2.Field<string>("Name");

跨表查询(LINQ to DataSet)

于 2013-02-08T11:30:40.530 回答