var result = booklist.GroupJoin(authorlist, authorlist2,
x => x.ISBN,
y => y.AuthorId,
z => z.AuthorID,
(x, y, z) => new
{
x.Book_Name,
y.AuthorName,
z.AuthorName
}).GroupBy(od => new
{
od.Book_Name,
od.AuthorName
}).OrderBy(d => d.Key.Book_Name).Select(grp => new
{
AuthorName = grp.Key.AuthorName,
Book_Name = grp.Key.Book_Name,
});
foreach (var item in result)
{
Console.WriteLine(string.Format(" BookName:- {0}\n AuthorName:- {1}\n", item.Book_Name, item.AuthorName));
}
enter image description here
这里我使用lambda函数打印了一本书和两个作者名,但是在GroupJoin上显示了错误。请检查并告诉我哪里出错了
1条答案
按热度按时间0lvr5msh1#
错误说明指出GroupJoin方法没有带六个参数的重载。GroupJoin只能通过两个导航属性联系两个列表,每个列表一个导航属性。
连接列表后,分组将如下所示: