Types in Union or Concat cannot be constructed with hierarchy
- by user927777
I am trying to run a query very similar to the following:
(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"
});
I am receiving "Types in Union or Concat cannot be constructed with hierarchy" after the statement executes, I need to to be able to get a list of categories to display with each book. If anyone could shed some light on a possible solution, it would be greatly appreciated.