Just for learning, understand the section. I made a lambda from a bank with only 6 fields, like this:
public List<LiberacaoDTO> getAutoriza(int idorcamento)
{
var lista = contexto.Liberacoes
.Where(m => m.IdOrcamento == idorcamento)
.Select(m => new LiberacaoDTO
{
TipoVenda = m.TipoVenda,
Juros = m.Juros != 0 ? m.Juros : 0,
Entrada = m.Entrada != 0 ? m.Entrada : 0,
MaxComi = m.MaxComi,
Cliente = m.Cliente,
Filial = m.Filial
})
.ToList();
return lista;
}
When the service returns, it brings up all the fields. Only those listed in the expression, value, the others have null or 0. But why all the fields and not only those listed in the expression? Below is my service call:
public class LiberacaoController : ApiController
{
AutorizadorContext contexto = new AutorizadorContext();
PedidoLiberacao liberacao = new PedidoLiberacao();
[AcceptVerbs("Get")]
public IEnumerable<LiberacaoDTO> getLiberacao()
{
return liberacao.getAutoriza(1000012093).AsEnumerable().ToList();
}
}