I have a lambda expression that I\'d like to be able to pass around and reuse. Here\'s the code:
public List getJobs(/* i want to pass the lambd
Use a FuncQuery:
public List getJobs(Func lambda)
{
using (SqlConnection connection = new SqlConnection(getConnectionString())) {
connection.Open();
return connection.Query(sql,
lambda,
splitOn: "user_id",
param: parameters).ToList();
}
}
You would call it:
getJobs((job, student) => {
job.Student = student;
job.StudentId = student.Id;
return job;
});
Or assign the lambda to a variable and pass it in.