简体   繁体   中英

C# Join two DataTables Linq to obtain flatten results

There are 2 datatables structured in this way:

  • First DataTAble has two cols: Customer, Email_Key
  • Second DataTAble has two cols: IdCustomer (equals Email_Key), Email

Foreach row in Dt1 can correspond many rows in Dt2 (1 to N) joining EmailKey on CustomerId, so I want to flatten result inside 1 record by using the SelectMany func. How can I achieve this?

I don't think SelectMany is what you're looking for. SelectMany .

Depending on what you are trying to do, You can try Union or distinct. You might want to rephrase your question slightly, including if you are trying to "flatten" the results in the select or in code(after you have populated the DataTables).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM