1
the problem is:
I have a dropdownlist loaded from an Enum, which can 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’t use ToString()
within the lambda
, I wonder if there’s a way I can make that comparison, in my ActionResult
i get from the screen the value of DDL
as string
, and when comes the value null
, doesn’t 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
Creation of dropdownlist
:
@Html.DropDownList("ddlCategoriaDiurna",
(ViewBag.CategoriaDiurna as SelectList),
string.Empty)
Como sabem, não da pra usar ToString
I don’t know about that, can you explain what the problem is? Actually tell me where the problem is, what’s going on, what should happen, what you’re talking about.– Maniero
So, Tostring or any conversion to string does not work inside Lynne, because there is something similar in the database. The problem occurs on the line that compares Categoriadiurna to the one selected in the dropdownlist that comes from the screen. In the case o.Categoriadiurna is an Enum, and ddlCategoriaDiurna is a string, I would like to know how to compare this inside the lambda.
– AbnoanMuniz
Is using in database, already helps explain. The
Enum
also does not exist.– Maniero