Types in Union or Concat cannot be constructed with hierarchy
Posted
by
user927777
on Stack Overflow
See other posts from Stack Overflow
or by user927777
Published on 2012-10-07T20:14:09Z
Indexed on
2012/10/07
21:37 UTC
Read the original article
Hit count: 166
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.
© Stack Overflow or respective owner