Linq left-joining like tables

故事扮演 提交于 2019-12-25 00:29:50

问题


I have 2 datatables of identical structure, and I need to find all records that appear on the first, but not on the second. What makes it more complicated is that the matching needs to be on 3 columns instead of one.

Background - I'm writing a replication process where rows of data arrive in an XML transaction and they need to be matched against the 'host' database to find out if there are any items that need to be added. The basic algorithm is as follows:

  1. Load in transaction dataset containing several datatables
  2. Create a new datatable and populate with the 'host' entries from the local database
  3. Run a match between them to find out which are the 'new' records
  4. Iterate through said 'new' records and create the objects in the database.

I've seen many examples of LEFT JOIN in LINQ but I can't seem to find anything that specifically meets my needs. It would be easy if the tables were joined on one column, but unfortunately this is not the case....

Any help would be appreciated.

Thanks,

Tim


回答1:


See Microsoft's 101 LINQ Samples. There is a LEFT OUTER JOIN example that should help you out.



来源:https://stackoverflow.com/questions/6658471/linq-left-joining-like-tables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!