I hope you can help me with this.
I want to convert this query from SQL in a lambda expression in C#:
select
a.Descripcion
from
pb.MantenimientosTipos a
where
a.activo = 1 and
a.idSegmento in (select b.idSegmento
from pb.MaquinasRelSegm b
where b.idMaquina = 67)
How can I do this?
I have two selectList, "a" and "b", the selectList "a" is list from table b filter by a parameter and the selectList "b" is a list from table a filter by SelectList "a"
private SelectList a (bool agregarTodo = false)
{
var segmentos = pb.MaquinasRelSegm.Where(x => x.idMaquina == MaquinaId).Select(x => x.Segmentos).ToList();
if (agregarTodo)
{
segmentos.Add(new PB.Domain.Entities.Segmentos { idSegmento = 0, Descripcion = "Todos" });
}
return new SelectList(segmentos, "idSegmento", "Descripcion");
}
private SelectList b (byte idSegmento, bool agregarTodo = false)
{
var tipos = pb.MantenimientosTipos.Where(x => x.idSegmento == idSegmento && x.Activo).ToList();
if (agregarTodo)
{
tipos.Insert(0, new PB.Domain.Entities.MantenimientosTipos { idTipoMTTO = 0, Descripcion = "Todo" });
}
return new SelectList(tipos, "idTipoMTTO", "Descripcion")
}
I want to put only one selectList with this SQL query
This is the relationship in SQL SERVER https://drive.google.com/file/d/0BzpCEYwGGpogRGRaOVNXTDBrTWc/view?usp=sharing