Which List Findall method is used in a Datatable

Asked

Viewed 157 times

1

I have the following select below:

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

I had to change my typed class to a DataTable I’m just not able to change select to fetch all the corresponding data in the following filter:

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

1 answer

2


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

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

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

  • It didn’t work out that way, I’m using Framework v2.0 and many things don’t compile on IIS, but I managed using select DataRow[] Filhos = FluxoWorkflow_&#xA; .Select("[IdPai] =" + dr["IdFluxoWorkflow"]); . Thanks for the tips.

  • 1

    Quiet. Nice to be able to help a little.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.