Use DataTransferObjects(DTO).
public class MaterialDTO
{
public string Code { get; set; }
public string Color { get; set; }
public string Description { get; set; }
public string Picture { get; set; }
public string MatType { get; set; }
}
Then complete it with info:
List<MaterialDTO> listForGrid = context.Material.Select(e=>new MaterialDTO(){Code=e.Code, Color = e.Color, Description = e.Description, Picture = e.Picture, MatType = e.MaterialType.MatType}).ToList();
This example gets whole data from the DB from Table Material
, and puts it to List<MaterialDTO> listForGrid
. Maybe you will also want to put Where
before the Select
, to take only part of data from the table but not the whole table.
Then bind this data to Grid...