如何在Linq子句中包含一个字符串值中的一个参数?

时间:2014-10-21 15:07:36

标签: vb.net linq where

我想对这个Linq有所帮助,我需要根据字符串值在Linq子句中包含不同的字段。

下面的Linq很好,我只是不能插入"和IIf(genero =" i",vc.modelo_id = 3,vc.sexo = genero)_&#34 ;。有人能帮助我吗?!

shirts = _
            From vc In db.VarCamisetas _
            Join m In modelos On vc.modelo_id Equals m.id _
            Join ca In db.Camisetas On vc.camiseta_id Equals ca.camiseta_id _
            Where _
              ( _
                ((vc.disponivel_dtg = 0 And vc.qtd_estoque > 0) And vc.Camiseta.disponivel_dtg = 0) _
                Or _
                ( _
                    ((vc.disponivel_dtg = 0 And vc.qtd_estoque > 0) And vc.Camiseta.disponivel_dtg = 1) _
                    Or _
                    ((vc.disponivel_dtg = 1 And vc.qtd_estoque_canvas > 0) And vc.Camiseta.disponivel_dtg = 1) _
                ) _
              ) _
              And vc.ativo = 1 _
              And vc.Camiseta.ativo = 1 _
              And vc.Camiseta.ocultado_catalogo = 0 _
              And vc.preco > 0 _
              And IIf(genero = "i", vc.modelo_id = 3, vc.sexo = genero) _
            Select _
              id = vc.camiseta_id, _
              vid = vc.varcam_id, _
              r = vc.Camiseta.ranking_popularidade, _
              p = vc.preco - vc.desconto, _
              t = vc.tamanho.Replace("xxg", "ggg").Replace("xg", "gg"), _
              c = vc.cor_basica.ToLower(), _
              m = vc.modelo_id, _
              g = m.sexo, _
              d = vc.Camiseta.Design.DesignProducaoModelos.lancamento_id, _
              cm = m.value, _
              dl = ca.data_ultimo_lancamento _
            Order By dl Descending, id Descending

0 个答案:

没有答案