How do I create object for IQueryable in C#?

I am trying to create and Instantiate IQueryable<T> object in my C# MVC project, but I am not able to create it, I would like to use it instead of List<T> = new List<T>, so how can I do it? I am trying this

 IQueryable<SFLoginMainView> sflogins = new IQueryable<SFLoginMainView>();

But this is not working, Visual Studio is showing error.

Asked by:- bhanu
: 7545 At:- 5/28/2020 1:25:35 PM
C# iqueryable create object

1 Answers
profileImage Answered by:- vikas_jk

You can create it like this

IQueryable<DataType> = Enumerable.Empty<DataType>().AsQueryable();

So, suppose your DataType = "Students" class or model, then it would be like this

IQueryable<Students> = Enumerable.Empty<Students>().AsQueryable();

That's it.

At:- 5/28/2020 2:11:46 PM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use