我正在尝试运行与以下非常相似的查询:
(from bs in DataContext.TblBookShelf
join b in DataContext.Book on bs.BookID equals b.BookID
where bs.BookShelfID == bookShelfID
select new BookItem
{
Categories = String.Join("<br/>", b.BookCategories.Select(x => x.Name).DefaultIfEmpty().ToArray()),
Name = b.Name,
ISBN = b.ISBN,
BookType = "Shelf"
}).Union(from bs in DataContext.TblBookShelf
join bi in DataContext.TblBookInventory on bs.BookID equals bi.BookID
select new BookItem
{
Categories = String.Join("<br/>", bi.BookCategories.Select(x => x.Name).DefaultIfEmpty().ToArray()),
Name = bi.Name,
ISBN = bi.ISBN,
BookType = "Inventory"
});
语句执行后,我收到“不能使用层次结构构建联合或 Concat 中的类型”,我需要能够获得要与每本书一起显示的类别列表。如果有人能对可能的解决方案有所了解,将不胜感激。