3

I'm trying to achieve this in c#

Select a.Name,a.Param
from Customization a
where a.name in (select Name from Standard)

I have try something like this but it still doesn't work.

 merge = dt1.AsEnumerable()
            .Where(r => r.Field<string>("Name")
            .Contains(dt2.Rows.Contains("Name")))
            .CopyToDataTable();
K.S
  • 33
  • 3

1 Answers1

3

By using the current way we need to get the name list from the second data-table(dt2) for each row in dt1 so I suggest you get the list of names first and then check whether r.Field<string>("Name") contains in the collection. For this, you can use the following code

var NameCollection = dt2.AsEnumerable().Select(x=> x.Field<string>("Name")).ToList();

merge = dt1.AsEnumerable()
           .Where(r => NameCollection.Contains(r.Field<string>("Name")))
           .CopyToDataTable();
sujith karivelil
  • 28,671
  • 6
  • 55
  • 88
  • i'll accept it once the cooldown timer for accepting has off. Once again thank you very much ! – K.S Jul 19 '17 at 07:21