I have a model class which also includes a fileContent (byte[]) property. Is it possible to exclude the fileContent property from getting filled with its content when the class is loaded/retrieved?
// My Class/Model
public partial class empLeaves
{
public string empId { get; set; }
public string leaveId { get; set; }
public System.Guid fsguid { get; set; }
public string fileNameOrig { get; set; }
public byte[] fileContent { get; set; }
}
Loading/retrieving data in controller/dataLayer as follows:
emp_leaves = db.empLeaves.Include(i => i.empLeaveApprovals.Select(q => q.approvalType))
.Include(i => i.empmaster)...
.Where(m => m.ID == id).Single();
In my view, I am passing the model object, which carries the whole data, which is unnecessary. the file content would be required only when the user chooses to download it.
I know I could use a ViewModel, but have kept it for last, since this table has a lot of columns and keeps adding up very often. Seeking any other easier way out. Another option [dirty option] i have thought of is to set the column value to null before passing to view. But i would prefer that fileContent is not loaded at all.