0

This problem follow a preceding post ( Dynamic Where in linq MVC)

if (search.anno != null)
    where = " ANNO = @0 ";
  parameters = new object[] { search.anno };

if (search.Cliente != null)
{
    if (!string.IsNullOrEmpty(where))
    {
        where += " && CODICE_CLIENTE = @1";
        parameters = new object[] { search.anno, search.Cliente };
    }
    else
    {
        where = " CODICE_CLIENTE = @0";
        parameters = new object[] { search.Cliente };
    }
}

if (search.linea != null)
{
    if (!string.IsNullOrEmpty(where))
    {
        where += " && LINEA.Contains(@2) ";
        parameters = new object[] { search.anno, search.Cliente, search.linea };
    }
    else
    {
        where = " LINEA.Contains(@0) ";
        parameters = new object[] { search.linea };
    }
}

I cant use LINEA.Contains because in my model LINEA is anonimous type string How can solve the filter for LINEA?

Community
  • 1
  • 1
jon
  • 13
  • 1
  • 8
  • What are you trying to express by something like `LINEA.Contains({ search.anno, search.Cliente, search.linea }) `? – Gert Arnold Apr 09 '17 at 20:06
  • I try to add parameters to Where(myStringWhere,parameters). Firts two filter works but the last not works – jon Apr 09 '17 at 20:20
  • stackoverflow.com/questions/43201615/ here is my logic – jon Apr 09 '17 at 20:23
  • I get an error say string LINEA not has Contains method. Linea is an anonimous property that i temporary use in my model. – jon Apr 09 '17 at 20:28
  • I guess what I trying to ask is: what exactly should `LINEA.Contains(@2)` do? What do you expect `LINEA` to contain? It's just that I wonder if this `Contains` makes sense. I think you want to test if a list of strings contains `LINEA`. – Gert Arnold Apr 09 '17 at 20:31
  • I would test if one or more of 3 check boxes is selected. LINEA is Product lines. My search model contains a property string[] linea. So yes, i would test if one or more of value in checkbox is contained in LINEA. what i wrong? – jon Apr 09 '17 at 20:55
  • If it is a single option as radiobutton is easy but in that case there are multiple select. – jon Apr 09 '17 at 20:58

0 Answers0