LINQ EQUIVALENTE AO IN() POO

MAXCIM 16/03/2016 14:11:13
#459287
olá amigos,

usando métodos POO qual seria o equivalente ao

select * from tbl_CST_ICMS ICMS where (ICMS.cst in([Ô]10[Ô],[Ô]30[Ô],[Ô]60[Ô],[Ô]70,[Ô]90[Ô] ));

para consultar um classe com LINQ?

desde ja agradeço
MESTRE 16/03/2016 14:18:13
#459291
Citação:

:
olá amigos,

usando métodos POO qual seria o equivalente ao

select * from tbl_CST_ICMS ICMS where (ICMS.cst in([Ô]10[Ô],[Ô]30[Ô],[Ô]60[Ô],[Ô]70,[Ô]90[Ô] ));

para consultar um classe com LINQ?

desde ja agradeço


https://msdn.microsoft.com/pt-br/library/bb397927.aspx
e
https://msdn.microsoft.com/pt-br/library/bb397676.aspx
ELUCIMAR 16/03/2016 15:11:39
#459312
Resposta escolhida
MAXCIM, Seria mais ou menos assim:

public class TblCstIcms
{
public int AliquotaIcms { get; set; }
public string Cst { get; set; }
}


private void button1_Click(object sender, EventArgs e)
{
List<string> lstCstPesquisa = new List<string> {[Ô]10[Ô],[Ô]30[Ô],[Ô]60[Ô],[Ô]70[Ô],[Ô]90[Ô]};
List<TblCstIcms> lstTblCstIcms = new List<TblCstIcms>();
lstTblCstIcms.Add(new TblCstIcms() {AliquotaIcms = 17,Cst = [Ô]00[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 12, Cst = [Ô]00[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 7, Cst = [Ô]10[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 19, Cst = [Ô]00[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 7, Cst = [Ô]00[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 0, Cst = [Ô]30[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 7, Cst = [Ô]00[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 17, Cst = [Ô]00[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 0, Cst = [Ô]60[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 19, Cst = [Ô]00[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 17, Cst = [Ô]90[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 17, Cst = [Ô]00[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 12, Cst = [Ô]70[Ô] });
lstTblCstIcms.Add(new TblCstIcms() { AliquotaIcms = 17, Cst = [Ô]00[Ô] });

// Exemplo 1
List<TblCstIcms> lstTblCstIcmsPesquisa1 = lstTblCstIcms.Where(l => lstCstPesquisa.Contains(l.Cst)).ToList();

// Exemplo 2
List<TblCstIcms> lstTblCstIcmsPesquisa2 = lstTblCstIcms.Where(l => lstCstPesquisa.Exists(x => x == l.Cst)).ToList();

// Exemplo 3
List<TblCstIcms> lstTblCstIcmsPesquisa3 = (from tbl in lstTblCstIcms
where lstCstPesquisa.Contains(tbl.Cst)
select new TblCstIcms
{
AliquotaIcms = tbl.AliquotaIcms,
Cst = tbl.Cst
}).ToList();


}
Tópico encerrado , respostas não são mais permitidas