我想做一个两个不同的linq结果的连接查询有人请帮忙 第一个结果:
var result3 = (from i in db.SUP_Seek_Education
group i.Univ_Name by new { i.Seek_Resume_ID } into g
select new
{
count = g.Key.Seek_Resume_ID,
Items = g.Select(w => w).Distinct()
}).ToList().Select(o => new { o.count,uni= string.Join(",",o.Items.ToArray())});
,第二个结果是:
var list = (from n in db.SUP_Seek_Personal
join b in db.SUP_SeekerProfileImage on n.Seek_Per_ID equals b.Seek_Per_ID
into a
from b in a.DefaultIfEmpty()
join c in db.SUP_Seek_WebUser on n.Seek_Per_ID equals c.Seek_Per_ID
join d in result2 on n.Seek_Per_ID equals d.Seek_Per_ID
join e in result3 on d.Seek_Resume_ID equals e.count
select new
{
firtname = n.FirstName,
secondname = n.LastName,
// university = e.uni,
perid = n.Seek_Per_ID,
filename = b.ImageType,
imagetype = (b.ImageType == 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 :(得分:0)
据我所知,这是不可能的。序列只有在具有相同类型时才能连接;你可以选择普通类型object
。
答案 1 :(得分:0)
我假设你想要某种POCO ex:
public class Element
{
internal string firtname { get; set; }
internal string secondname { get; set; }
internal decimal perid { get; set; }
internal string filename { get; set; }
internal string imagetype { get; set; }
internal string uni { get; set; }
}
创建列表时,使用选择新元素,而不是选择新。之后:
foreach (var item in result3)
list.FirstOrDefault(o => o.perid == item.count).uni = item.uni;
有用的提示:Linq使用延迟加载但是如果您 .ToList()查询已实现,因为数据是从数据库中提取的。在这种情况下,使用 .ToList()结束行是有意义的。