Let's say I have a model like this:
public class Model {
[Key]
public int Id { get; set; }
public string SmallData { get; set; }
public byte[] VeryLargeBlob { get; set; }
}
I need to read an entity from the database and use only the field SmallData, and the VeryLargeBlob is not needed. VeryLargeBlob is very large (say, several megabytes) and reading it from database can affect performance.
I understand that I can choose some of the fields in this way:
var data = context.Model.Where(m => m.Id == Id).Select(m => new { Id = m.Id, SmallData = m.SmallData }).FirstOrDefault();
But I need a Model instance and not an anonymous object, so that I can use it for later queries. Even if I hack it and make it return a Model object the instance isn't tracked and won't be compatible with lazy loading.
Is there a way to load only partial data from the model?

