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
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.
- How to combine 2different IQueryable/List/Collection with same base class? LINQ Union and Covariance issues
- How can you use LINQ to cast from a collection of base class objects to a filtered list of their respective subclasses?
- LINQ Query over heterogeneous collection of different types with same base class
- getting same type of inherited class items from base class list using linq
- How to filter a list with linq depends on counting a property at the same list and take a random group at least minimum total
- How to order list in custom Item class with linq query
- Combine contents of list member of object collection into single list with linq
- List of class objects - Filter class objects with same values using LINQ
- How to use Linq or Lambda with IQueryable to GroupBy and get the first/last record on the collection in C#?
- How to creat a new list from existing list with elements which contains the same id in Linq to object?
- Linq Sorting on list and its nested collection of same class
- How to remove duplicates in List of Class with Linq
- How to Return class with list using LINQ in C#?
- How to merge a list of lists with same type of items to a single list of items?
- How to Count Duplicates in List with LINQ
- linq how to select a parent with a child collection that contains one or many of an array (or list) of values
- How to update an element with a List using LINQ and C#
- How to implement SkipWhile with Linq to Sql without first loading the whole list into memory?
- How to sort a List collection of classes with properties in them?
- How can I iterate over a collection and change values with LINQ extension methods?
- How do I convert IEnumerable to Collection with linq
- Linq with custom base collection
- LINQ method How to SelectMany with additional column from Parent class
- How to write a LINQ to Entities query with List in a "WHERE" condition
- C# - Combine multiple LINQ collections with same properties
- How can I split a list vertically in n parts with LINQ
- How to convert list of objects with two fields to array with one of them using LINQ
- How do you sort a String List by the number of words matched with an Array in Linq
- How can I combine this code into one or two LINQ queries?
- LINQ Union between two tables with the same fields and then returned in a collection
More Query from same tag
- NHibernate - LINQ Query Many to Many Issue
- Linq to Entities - where statement throws System.NotSupported Exception
- Searching a list using an array as the parameter list using LINQ
- LINQ help for a beginner selecting multiple tables
- The cast to value type 'Int32' failed null value LINQ
- Preventing recursion during DataContext.SubmitChanges()
- How to write linq query for this SQL query?
- LINQ - Projection with grouping and Let local variable
- LINQ to XML is throwing an exception and I can't figure out why
- Convert SQL update query to c# LINQ code
- How can I use SelectMany on my IQueryable of classes?
- Get records which do not start with an alphabetical character in linq
- How can I pass TotalRowCount to DataPager
- How to select all objects that have a property value in list of values?
- Why is this query resolving to a DataQuery
- Inner Join in LINQ not working correctly
- EF - AND NOT EXISTS (SELECT 1 ...) with Entity Framework
- Parsing soap response with LINQ
- How to group by multiple generic linq expressions
- Asp.Net MVC Rollback Changes?
- SQL to Linq for inner and left join together
- Use IEqualityComparer to generate a distinct list based on two properties in C#
- Repository Pattern Access Multiple Tables?
- How can I check for a null inside of a linq query?
- How can I perform a nested Join, Add, and Group in LINQ?
- How do I perform Date Comparison in EF query?
- How to share a given integer number and it's remainder across any number of people with LINQ?
- XML to Dictionary using Linq - Not getting Child values
- Take slice from 2D array (int[ , ]) using LINQ in C#
- Linq Queries - How to join the below two group by queries? On Course ID