1
I have the following model called Conta
:
public int Codigo { get; set; }
public string Nome { get; set; }
public int Prazo { get; set; }
assuming I want to select (without using lambda) and bring only the Name property, in which case I created a struct:
struct getNomeConta
{
public string Nome { get; set; }
}
and made the select:
getNomeConta = db.Database.SqlQuery<getNomeConta>(strSql).FirstOrDefault();
where strSQl
is my SQL string that brings the name value only.
This code was made in a hurry to meet the requisitor, but I want to change it, preferably using lambda to select, but with only the name (without having to load the model Conta
whole)
In fact when bringing the data from
Conta
you carry the Model all anyway. Bring all the columns or do not generate impact on the performance, whether this is the concern.– Leonel Sanches da Silva