Using the result of an Iqueryable list from one query as a parameter to another?

I'm new to query and can't find a way to use the query result list as a validation for another query, is this possible?

var query = from weather_variables in weather
where weather_variables.area == choice
select weather_variables.wind_speed;

      

This is where a set of monthly wind speeds is selected from the database

var power_query = from wind_turbines in power
where wind_turbines.wind_speed = query
select wind_turbines.xxxxxx;

      

Here I want to get records that correspond to each wind speed in the list, but as a set of it, not an individual value, I cannot match where this is happening, is there any other way to form this query that would allow me to check the usage of the output queries ?

EDIT: I need output for each of the values ​​from the list, the usage only contains values ​​that are not the same as each other. those. 2 months have the same wind speed, only one way out of the second request is provided

+3


source to share


1 answer


var query=weather.Where(w=>w.area==choice).Select(w=>w.wind_speed);
var power_query=power.Where(p=>query.Contains(p.wind_speed)).Select(p=>p.xxxxx);

      

Check in:



var result=weather
  .Where(w=>w.area==choice)
  .Join(power,j1=>j1.wind_speed,j2=>j2.wind_speed,(j1,j2)=>j2.xxxx);

      

+1


source







All Articles