考虑以下代码:
var list = from n in Personal
join b in SeekerProfileImage on n.Seek_Per_ID equals b.Seek_Per_ID
into a
from b in a.DefaultIfEmpty()
join c in Resume on n.Seek_Per_ID equals c.Seek_Per_ID
join d in Education on c.Seek_Resume_ID.Min() equals d.Seek_Resume_ID
where ( Convert.ToBoolean((c.Seek_Resume_ID).Min()))
select new
{
firtname=n.FirstName,
secondname=n.LastName,
university = d.Univ_Name,
perid = n.Seek_Per_ID,
filename = b.ImageType,
imagetype = (b == null ? "http://localhost:10057/JobSearch/images/advertisment/head-silhouette.png" : "http://localhost:10057/JobSearch/images/SeekerIMG/" + n.Seek_Per_ID + "." + b.ImageType)
// imagetype = (b == null ? Server.MapPath("~images/advertisment/head-silhouette.png") : b.ImageType)
};
我想加入简历和教育,但仅限于每位员工的最低恢复时间。我该怎么做?以上是错误的。
答案 0 :(得分:1)
要将您的Resume集合转换为每个EmployeeID的一个简历集合,您可以将以下表达式应用于Resume。这将按EmployeeID对简历进行分组,按ResumeID对每个组进行排序,然后选择每个有序组中的第一个。
Resume.GroupBy(r => r.EmployeeID).Select(gr => gr.OrderBy(r => r.ResumeID).First());