im using Entity Framework designer first and I need to create custom Model Objects starting from the db objects. I don\'t want to use IEnumerable cause it will query too many fi
I think that I need to use something like this: [snip] but I really can't figure out how to use it.
That's exactly what you need, but you also need LINQKit to make the query work. With it, your code would look like this:
var toModel = ToModel();
var departments2 = db.departments
.AsExpandable()
.Include(p => p.employee)
.Where(p => true)
.Select(p => new CustomDepartmentModel()
{
ID = p.ID,
Employees = toModel.Invoke(p.employee).ToList()
});