LINQ Equivalent query

Posted by GilliVilla on Stack Overflow See other posts from Stack Overflow or by GilliVilla
Published on 2012-08-27T21:36:18Z Indexed on 2012/08/27 21:38 UTC
Read the original article Hit count: 212

Filed under:
|
|
|
|

I have a

 List<string>     

List<string> students; 
students.Add("123Rob"); 
students.Add("234Schulz"); 

and a

Dictionary<string,string> 

Dictionary<string, string> courses = new Dictionary<string, string>(); 
courses .Add("Rob", "Chemistry");   
courses .Add("Bob", "Math");  
courses .Add("Holly", "Physics"); 
courses .Add("Schulz", "Botany");

My objective now is to get a List with the values - {Chemistry,Botany} .

In other words, I am trying to get the LINQ equivalent of

select value from [courses]
where [courses].key in 
(
select [courses].key from courses,students where [students].id LIKE '%courses.key%'
)

How should the LINQ query be framed?

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ