加入LINQ查询



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

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

现在我想加入另一个数据表dtRowFile,它包含两个字段"Name"one_answers"F2",其中字段"F2"将与数据表中的"F10"匹配

这有帮助吗:

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")
      };
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)

相关内容

  • 没有找到相关文章

最新更新