加入从不同的源数据库中的两个数据表中的.NET? [英] Join two data tables from different source databases in .NET?

查看:127
本文介绍了加入从不同的源数据库中的两个数据表中的.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么加入.NET从不同的源数据库中的两个数据表?理想情况下,我可以手动手艺两个查询,并只需​​加入单一领域。

How do you join two data tables from different source databases in .NET? Ideally, I can craft two queries manually and simply join on a single field.

在这种情况下,链接的服务器,并计划进口不是一种选择。我已经研究过的数据关系对象,但(纠正我,如果我错了),其仅适用于亲子关系。

In this case, linked servers and scheduled imports are not an option. I've looked into the data relation object, but (correct me if I'm wrong) that only works for parent-child relationships.

推荐答案

我也有类似的情况,我有2个数据表,并加入了他们使用LINQ。

I had a similar situation where I had 2 datatables and joined them using LINQ.

下面是我的情况,code,也许它会帮助你。

Here is the code from my situation, maybe it'll help you out.

  var combinedRows = 
         from t in dt_t.AsEnumerable()
         join sap in dt_sap.AsEnumerable() on t.Field<System.Int32>("line_no").ToString() equals sap.Field<System.String>("PO_Item")                           
         orderby t["line_no"]
         select new { t, sap };

这篇关于加入从不同的源数据库中的两个数据表中的.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆