I've got an SQL table that stores a person record where one column is an image. I'm using the table in an ASP.Net MVC application and I only want to retrieve the image column in the controller action that is used by my HTML image source attribute.
How can I prevent the column storing the image from being retrieved by my LINQ query without having to resort to explicitly requesting every desired column but still be able to retrieve it with an explicit request?
This is the LINQ expression I don't want to return the image column in (there are about a dozen includes so explicitly specifying each property is not an option):
Person person = (from per in entities.People.Include(...).Include(..)
where per.ID == id
select per).FirstOrDefault();
The LINQ expression I use to get the image is:
byte[] picture = (from per in entities.People
where Per.ID == id
select per.Picture).FirstOrDefault();