更新时间:2023-02-15 19:39:43
使用一个 函数功能:LT; T1,T2,TResult>
委托作为参数类型,并把它传递到您的查询
:
public List<IJob> getJobs(Func<FullTimeJob, Student, FullTimeJob> lambda)
{
using (SqlConnection connection = new SqlConnection(getConnectionString())) {
connection.Open();
return connection.Query<FullTimeJob, Student, FullTimeJob>(sql,
lambda,
splitOn: "user_id",
param: parameters).ToList<IJob>();
}
}
您会称之为:
getJobs((job, student) => {
job.Student = student;
job.StudentId = student.Id;
return job;
});
或者拉姆达分配给一个变量,并通过的它在