I need to mount a drop-down with part of the name of a project, which is very large in the database, going up to 250 characters. For this I made a selector like this:
var lista = _projetoAppServ.ObterTodos("Descricao")
.Select( a => new {
ProjetoId= a.ProjetoId,
Descricao = a.Descricao.Substring(0,50)
})
However, there are projects with less than 50 characters, causing the error below: Index and length must refer to a location within the string. Parameter name: length
How can I solve this problem?