I want to create a list of empty IQueryable and change it to ToPagedList, I tried the following code :-
IQueryable<VirtualMachine> vm2 = new IQueryable<VirtualMachine>();
vm2.ToPagedList(page, pagesize);
but it will raise the following exception:-
Error 3 A new expression requires (), [], or {} after type
Alternatively, you can create an empty list with the type constructor list (), which creates a new list object. If no argument is given, the constructor creates a new empty list, [].
The List class’s constructor can convert an IQueryable for you: public static List<TResult> ToList<TResult>(this IQueryable source) { return new List<TResult>(source); } or you can just convert it without the extension method, of course: var list = new List<T>(queryable); Reply↓ userNovember 30, -0001 at 12:00 am Then just Select:
Object Set<TEntity> More… The IQueryable<T> interface is intended for implementation by query providers. This interface inherits the IEnumerable<T> interface so that if it represents a query, the results of that query can be enumerated.
Returns the maximum value in a generic IQueryable<T>. Invokes a projection function on each element of a generic IQueryable<T> and returns the maximum resulting value. Returns the maximum value in a generic IQueryable<T> according to a specified key selector function.
You could use something like this
IQueryable<VirtualMachine> vm2 = new VirtualMachine[] {}.AsQueryable();
Do you actually want / need this though? as on MSDN, the IQueryable interface is for use on data sources.
Provides functionality to evaluate queries against a specific data source wherein the type of the data is known.
I would decide whether or not you actually need this before implementing it like this.
You can't create an instance of an interface - there's no implementation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With