I'm running a query using Select
, to select only the required fields and consequently to have higher performance.
In my View
user can choose certain fields to load
My ViewModel
public class CliViewModel {
public bool CarregarNome {get;set;}
}
and in my select
var entity = context.Clientes.AsNoTracking()
.Select(cli => new {
if(viewModel.CarregarNome) {
x.Nome
}
}).ToList();
Of course this expression of the error, but is there any way to do something similar?