Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
var query1=entities.Table1.Where(x=>x.TypeID=="4").Select(x=>x.ID).ToList();

var query2=entities.Table2.Where(x=>x.PID==2)Select(x=>x.ID).ToList();


I'm pulling the same fields from two different tables.
The 2nd query retrieves the first query value.

What I have tried:

var query1=entities.Table1.Where(x=>x.TypeID=="4").Select(x=>x.ID).ToList();

var query2=entities.Table2.Where(x=>x.PID==2)Select(x=>x.ID).ToList();


I want to query2 include query1.So I write this query but not true run.

var query2=entities.Table2.Where(x=>x.PID==2 && x.Contains(query1))Select(x=>x.ID).ToList();
Posted
Updated 12-Jan-20 1:34am
Comments
[no name] 11-Jan-20 9:22am    
Should this not be more something like query1.Contains(x.ID)?

 
Share this answer
 
v2
I already answered your question here: How to write lambda linq query in C#?[^]

Please, respect the rules of QA forum[^] and do not repost questions!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900