score:2
Accepted answer
The difference between IQueryable
and IQueryable<T>
is that the second is typed while the first is not. To convert IQueryable
into IQueryable<T
> you can use the Cast<T>()
method.
IQueryable myQueryable = ...;
IQueryable<MyType> myTypedQueryable = myQueryable.Cast<myQueryable>();
IList<MyType> myList = myTypedQueryable.ToList();
Obviously the contents of myQyeryable
must be castable into MyType
. To select the instances of a certain type you can use the TypeOf<T>()
method before doing the cast.
Source: stackoverflow.com
Related Articles
- How to dynamic add filters to a LINQ query against an Odata Source in C#
- Dynamic query to immediate execute?
- How to execute code as a part of the LINQ query
- Execute dynamic query with Linq in Entity Framework
- Updating List using LINQ working when execute from Immediate window, not from code direct
- Dynamic query with OR conditions in Entity Framework
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'
- Trim() a list of strings using dynamic query language to produce a trimmed IQueryable<string>
- Does foreach execute the query only once?
- How to execute LINQ and/or foreach in Immediate Window in VS 2013?
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- does converting IQueryable to IEnumerable execute the query again?
- Syntax to execute code block inside Linq query?
- Query data using "Contains" keyword in Dynamic Linq in C#
- passing dynamic expression to order by in code first EF repository
- How can I build Linq query with dynamic OR statements?
- Dynamic query using LINQ to SQL
- LINQ TO SQL, Dynamic query with DATE type fields
- Dynamic linq query expression tree for sql IN clause using Entity framework
- The best way to build Dynamic LINQ query
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Dynamic Linq query Contains List
- Dynamic LINQ query to get Field value from Database
- Dynamic linq query with multiple/unknown criteria
- Creating a dynamic query using IQueryable
- linq query with dynamic predicates in where clause joined by OR
- How to write this Linq SQL as a Dynamic Query (using strings)?
- How does linq actually execute the code to retrieve data from the data source?
- How to cast a Linq Dynamic Query result as a custom class?
- Using LINQ Dynamic Query Library with Dictionary<string, object> and .AsQueryable()
- Does C# linq support "anti join" semantics?
- Linq to SQL check for null on object before accessing property
- How do I combine data from two rows with the same foreign key in sql/linq
- Replacing values with LINQ in a list with the previous value matching some criterion
- Split and join in C# using linq
- Removing a subset from a SuperSet based on a criteria using LINQ
- Filtering Out Object from Composite List C#
- Powershell equivalent of ".Single()" For a C#/Java programmer
- Mongodb c# driver Linq query Group by
- C# FileInfo - additional conditions in this LINQ query
- asp.net linq group by id
- LINQ update query is not updating database records in Xamarin forms app
- Datetime.UtcNow in Entity Framework query evaluated different than DateTime.UtcNow in C# IL
- Linq order by using query expression
- How to return partial results and the total count for a query with Entity Framework?
- Using .net functions to filter Entity Framework information
- add multiple xml elements value into a list
- How to return nullable datetime in ef linq query
- How can add an additional row to a LINQ query?
- Strange Exception thrown using Dynamic Linq Entity Framework Query