I have a projection mapping lambda that I use with a dynamic QuerySpec query in LLBLGen
var qf = new QueryFactory();
var q = qf.Create()
.From(qf.Leave.LeftJoin(qf.Student).On(LeaveFields.StudentId == StudentFields.StudentId))
.Where(pred)
.OrderBy(LeaveFields.RequestDate.Descending())
.Select( () => new LeaveDTO
{
LeaveId = LeaveFields.LeaveId.ToValue<int>(),
RequestDate = LeaveFields.RequestDate.ToValue<DateTime>(),
LeaveDepart = LeaveFields.LeaveDepart.ToValue<DateTime>(),
LeaveReturn = LeaveFields.LeaveReturn.ToValue<DateTime>(),
ApprovalType = LeaveFields.ApprovalType.ToValue<string>(),
StudentId = StudentFields.StudentId.ToValue<int>(),
SchoolId = StudentFields.Schoolid.ToValue<string>(),
FirstName = StudentFields.FirstName.ToValue<string>(),
LastName = StudentFields.LastName.ToValue<string>(),
});
I would like to reuse the projection lambda in other queries called in other functions:
() => new LeaveDTO
{
LeaveId = LeaveFields.LeaveId.ToValue<int>(),
RequestDate = LeaveFields.RequestDate.ToValue<DateTime>(),
LeaveDepart = LeaveFields.LeaveDepart.ToValue<DateTime>(),
LeaveReturn = LeaveFields.LeaveReturn.ToValue<DateTime>(),
ApprovalType = LeaveFields.ApprovalType.ToValue<string>(),
StudentId = StudentFields.StudentId.ToValue<int>(),
SchoolId = StudentFields.Schoolid.ToValue<string>(),
FirstName = StudentFields.FirstName.ToValue<string>(),
LastName = StudentFields.LastName.ToValue<string>(),
}
How?