The problem is:
I have a dropdownlist loaded from an enum, which may come with the null value of the screen.
listaItensSolicitados = os.Site == null ?
this.itemSolicitadoService.Consultar(o =>
o.ItemServico.Servico.Chave == 9 &&
o.ChaveOrgao == os.Orgao.Chave && o.Numero.Contains(ramal)
&& o.CategoriaDiurna == ddlCategoriaDiurna
&& o.Instalado == true
&& (o.Depreciado == null
|| o.Depreciado == false)).Take(200).ToList() :
As you know, you can not use ToString()
within lambda
, I would like to know if there is a way for me to make this comparison, in my ActionResult
I get the value of DDL
as string
, and when the value null
comes, it does not work.
@edit
This is my enum
:
public enum CategorizacaoRamaisEnum : int
{
[Description("Categoria 1")]
Categoria1 = 1,
[Description("Categoria 2")]
Categoria2,
[Description("Categoria 3")]
Categoria3,
[Description("Categoria 4")]
Categoria4,
[Description("Categoria 5")]
Categoria5,
[Description("Categoria 6")]
Categoria6,
[Description("Categoria 7")]
Categoria7,
[Description("Categoria 8")]
Categoria8,
[Description("Categoria 9")]
Categoria9,
[Description("Categoria 10")]
Categoria10,
[Description("Categoria 11")]
Categoria11
}
@edit 2
Creating dropdownlist
:
@Html.DropDownList("ddlCategoriaDiurna",
(ViewBag.CategoriaDiurna as SelectList),
string.Empty)