Title might be confusing, so let me explain. Let's pretend I have a Dbo that looks like this:
public class EmployeeDbo
{
public int EmployeeId { get; set; }
public string FirstName{ get; set; }
public string LastName{ get; set; }
public string EmployeeData { get; set; }
public string EvenMoreEmployeeData{ get; set; }
}
And then somewhere in my data access layer I have this code:
// employeeId is some param that gets passed into this method
var query = _dbContext.Employees.Where(e => e.EmployeeId = employeeId);
// Now I want to further modify the query. I just want to load SOME values from the DB, instead of all of them
// The problem I have is that now this is trying to assign query, which is IQueryable<EmployeeDbo> to IQueryable<{string FirstName, string LastName}>
query = query.Select(e => new
{
e.FirstName,
e.LastName
});
// More code here that is expecting IQueryable<EmployeeDbo>
So, to summarize my question, how can I just populate SOME properties in a dbo with data from the DB? I suppose I could create a new Dbo with only the data I want as properties, but can I avoid doing that?