0

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?

CRK
  • 337
  • 2
  • 10
  • Does `D1.Email_Key` equal as `D2.IdCustomer`? – Fabio Mar 30 '17 at 10:15
  • Yes @Fabio I've omitted, now I update – CRK Mar 30 '17 at 10:16
  • I don't know how to do this. Surely I don't want other people do the job, don't understand why u think this. – CRK Mar 30 '17 at 10:17
  • Flattening results will not really buy you a cup of coffee. After joining two tables You have a table(id, email[]). So you need two selects in your query : table.Select(x => x.email.Select(y => .....)) – jdweng Mar 30 '17 at 10:19
  • maybe u forget that is a datatable not a stongly typed object and with no relations or nested objects. – CRK Mar 30 '17 at 10:21
  • Simply give us example of output you expects? Do you want another DataTable or Dictionary of list of emails and customer id as a key – Fabio Mar 30 '17 at 12:36
  • I want a Dictionary of list of emails and customer id as a key – CRK Mar 30 '17 at 13:33
  • @Fabio have you the answer? – CRK Mar 30 '17 at 14:32

1 Answers1

0

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).

Community
  • 1
  • 1
  • foreach customer can correspond N emails. How can I group results in a flatten mode? – CRK Mar 30 '17 at 12:25