this is my code... but i need select only column to display in my Datagridview. I Need the code to select only some columns.. example
Select{t => t.usu_Login, t => t.usu_Login}
public List<tb_usuario> Get(FilterDefinition filter)
{
var contexto = new indNET_Entities();
IQueryable<tb_usuario> Consulta = contexto.tb_usuario.AsQueryable<tb_usuario>()
.Where(t => t.usu_Ativo == 1)
.OrderBy(t => t.usu_Login);
return Consulta.ToList();
}
Try this:
Well there is a few ways you could do this, the easiest way:
Alternatively you could create a class and substitute the new {} for the class and do it at the data layer level.
If you only want a limited number of columns and you intend to pass the result out of the method, first declare a concrete type to describe the elements.
Then you can use this in the return type for the method
And finally, use the type in your select.
And, of course, your callers should expect to get this as the result (or just use type inference with
var
).