问题
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.
回答1:
I had a similar situation where I had 2 datatables and joined them using LINQ.
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 };
来源:https://stackoverflow.com/questions/997847/join-two-data-tables-from-different-source-databases-in-net