Which method corresponding to the FindAll of the List is used in a DataTable

1

I have the following select below:

var Filhos = FluxoWorkflow_
                .FindAll(N => N.IdPai.GetValueOrDefault() == dr.IdFluxoWorkflow);

I've had to change my typed class to a DataTable I'm just not getting it to change the select to fetch all matching data in the following filter:

.FindAll(N => N.IdPai.GetValueOrDefault() == dr.IdFluxoWorkflow);
    
asked by anonymous 16.02.2016 / 17:23

1 answer

2

You can use the AsEnumerable() to "convert" your DataTable to a IEnumerable<T> , so you can use Where() to filter the data.

var Filhos = FluxoWorkflow_.AsEnumerable().
            .Where(N => N.IdPai.GetValueOrDefault() == dr.IdFluxoWorkflow);

Note: The methods FindAll() and Where() do the same thing . The difference between them is that FindAll() is a method of List<T> , so it can only be used for this type, while Where() is a System.Linq extension method and is applicable in any type that implements IEnumerable<T> .

    
16.02.2016 / 17:27