c# - How can I intersect two different .NET lists by a single property? -


I am trying to filter my first list of FU based on some values ​​in a second list of ba.

For example.

Here is ...

  var foos = new list & lt; Foo & gt; New fu {name = "lea"}, new fu {name = "han solo"}, new fu {name = "chewacka"}, new fu {name = "luke"},}; var bass = new list & lt; Left & gt; New Ba (Elias = "AAAA"), New Ba (Elias = "BBBB"), New Ba (Elias = "Laya"), New Ba (Elias = "Luke"}}; // Expected Output: // List & See how I'm asking for: another list  Alias ​​< / code> Filter by first list ( name ) by property.  

And will it return to a list of foo in 2 results?

any clue?

You can add baas to the list of < code> any :

  foos. where (f => baas.Any (b = & gt; B. alias == f.Name));   

or join (use cleaner in the query syntax):

  var from query = f to join foos b f. Choose an alias   

A complete working .net Bella.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -