Lim
Lim

Reputation: 135

Filtering DataTable with LINQ

i have two DataTables one with a hughe List of Results and one with a List of Companys from another DataBase.

Well i need to filter the Results on the Companys in the other DataTable.

Something like this:

DataTable Results

0 | FA1 | Resultx
1 | FA2 | Resulty
2 | FA3 | Resultz
3 | FA4 | ResultAA

DataTable Company

FA2
FA4

So i'm looking for a way to filter the first DataTable with the Results of the second DataTable.

Thanks Lim

Upvotes: 0

Views: 911

Answers (1)

Wouter de Kort
Wouter de Kort

Reputation: 39898

You could use Linq To Dataset. These are LINQ extension you can use against datatables.

This example shows you how do to a cross table query. It comes down to something like:

var query =
    from result in Results.AsEnumerable()
    join company in Companies.AsEnumerable()
    on result .Field<int>("....") equals
        company .Field<int>("....")
select new { .... }

Upvotes: 1

Related Questions