I have the following code which gives me an error:
The inline constraint of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: 'String'.
Exception Details: System.InvalidOperationException: The inline constraint resolving of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: 'String'.
//http://localhost:1608/api/ApiCidade/consulta/clienteLoginSenha/
[HttpGet]
[Route("consulta/clienteLoginSenha/{email:long};{senha:long}")]
public HttpResponseMessage ClientePorLoginSenha(string email, string senha)
{
try
{
var tCliente = new ClienteAplicacao();
var listarDeClientes = tCliente.ListarPorLoginSenha(email,senha);
return Request.CreateResponse(HttpStatusCode.OK, listarDeClientes.ToArray());
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
}
}
//http://localhost:1608/api/ApiCidade/consulta/clientePorNome/e
[HttpGet]
[Route("consulta/clientePorNome/{nome:String}")]
public HttpResponseMessage ClientePorNome(string nome)
{
try
{
var tCliente = new ClienteAplicacao();
var listarDeClientes = tCliente.ListarPorNome(nome);
return Request.CreateResponse(HttpStatusCode.OK, listarDeClientes.ToArray());
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
}
}
query that is in the application:
public List<Cliente> ListarPorNome(string nome)
{
var strQuery = string.Format("select * from clientes where nome like {0}", nome + '%');
using (contexto = new Contexto())
{
var retornoDataReader = contexto.ExecutaComandoComRetorno(strQuery);
return TransformaReaderEmListaObjetos(retornoDataReader);
}
}
private List<Cliente> TransformaReaderEmListaObjetos(SqlDataReader reader)
{
var clientes = new List<Cliente>();
while (reader.Read())
{
Cliente cliente = new Cliente()
{
Id = reader["id"] == DBNull.Value ? 0 : Convert.ToInt32(reader["id"]),
Nome = reader["nome"] == DBNull.Value ? string.Empty : reader["nome"].ToString(),
DataNascimento = reader["data_nascimento"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["data_nascimento"]),
Email = reader["email"] == DBNull.Value ? string.Empty : reader["email"].ToString()
};
clientes.Add(cliente);
}
reader.Close();
return clientes;
}