Good morning
I would like to ask you a question about a dynamic search.
Scenario:
I have a search screen where the user selects 3 fields, which are:
SohowwouldyoubestdevelopthisinC#?
- Createdropdownwithfieldvaluesandconditions.ThencreateamethodwhereIgetthevaluesinformedandthusgenerateaswitchcasewiththeconditionsdata?moreorlessthisway:
->
publicClientepesquisarCliente(stringcondicao,stringcampo,stringvalor){stringoperador="";
string sql;
switch(condicao)
{
case "Condendo":
operador = "LIKE %"+ valor +"%";
break;
case "Iniciando":
operador = "LIKE %"+ valor;
break;
case "Terminando":
operador = "LIKE "+ valor +"%";
break;
case "Igual":
operador = " = "+ valor;
break;
}
sql = "SELECT * FROM CLIENTES where @campo "+valor;
Com = new NpgsqlCommand (sql);
}
Would that be the best way? Would anyone else have developed this?
I do not know if I was clear in my doubt.
Thank you in advance for your attention.
I'm developing in C # layers with WPF and PostgreSQL database; I have the layers DAL, BLL, GUI and Model