Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IList<T> to IQueryable<T>

People also ask

How to convert List into IQueryable?

Is this the correct way to convert a List to an IQueryable List? List<Family> families = new List<Family>(); using (SqlConnection myConnection = new SqlConnection(connectionString)) { myConnection. Open(); SqlDataReader nwReader = selectTemp_DistinctFamilies_Command. ExecuteReader(); while (nwReader.

How do I add data to IQueryable?

The simple answer is that unless you add the record to the underlying datastore that the Iqueryable is querying, you can't add a new record into an IQueryable. So if you are using LinqToSql then you would have to add a row into the table that the IQueryable was querying in order to "add" a row into the IQueryable.

Is IQueryable faster than List?

Here is a test that i have setup this evening. It was made to prove something different, but the outcome was not quite as i expected. I'm running a test with 10000 random queries on an IQueryable and while testing i found out that if i do the same on a List, my test is 20 times faster.


List<int> list = new List<int>() { 1, 2, 3, 4, };
IQueryable<int> query = list.AsQueryable();

If you don't see the AsQueryable() method, add a using statement for System.Linq.


Use the AsQueryable<T>() extension method.