score:16

Accepted answer

Use the Cast operator:

IQueryable<ItemBase> folderItems = contractItems
        .Cast<ItemBase>()
        .Concat(changeOrderItems.Cast<ItemBase>());

The answer to the other question works for LINQ to Objects, but not necessarily for LINQ to Entities or LINQ to SQL.

Alternatively, you can convert to LINQ to Objects by calling AsEnumerable:

IQueryable<ItemBase> folderItems = contractItems
        .AsEnumerable()
        .Concat<ItemBase>(changeOrderItems);

However, take care in LINQ to Objects; Concat would work without any overhead (iterating through both collections from the database), but Union would pull one of the collections entirely from the database and then iterate through the other.


Related Query

More Query from same tag