Linq command to bring a decimal query C #

2

I'm having trouble understanding how to bring a query from the textbox of a column where the field is decimal?

if (txtNomePesquisar.Text.Equals(""))
{
    MessageBox.Show("O que você procura? ");
}
else 
{       
    var clientes = cc
          .TB_CLIENTEs.Where(c => c.NOM_CLIENTE.Contains(txtNomePesquisar.Text)).ToList();
    dgvCliente.DataSource = clientes;
}

if (txtTelPesquisar.Text.Equals(""))
{

/// a mensagem é  'decimal' does contain a definition for (Contains) and...
/// e fala de IQueryable mais não sei utilizar ainda
/// 
    var clientes = cc.TB_CLIENTEs
          .Where(c => c.TEL_CLIENTE.Contains(txtTelPesquisa.Text)).ToList();
}
    
asked by anonymous 26.10.2017 / 00:59

1 answer

0

First you have to check if the value is actually a decimal , you need to get the value of the text box and convert it to decimal , example:

decimal numero = 0;
if (decimal.TryParse(txtTelPesquisa.Text, out numero))
{
    var clientes = cc
          .TB_CLIENTEs
          .Where(c => c.TEL_CLIENTE == numero)
          .ToList();
}

If passed it returns true and executes everything that is within if and the comparison with decimal must be done with equality.

References

26.10.2017 / 01:28