Both are used to filter the records from the database. IQueryable ultimately inherits IEnumerable interface so all the feature of IEnumerable exists into IQueryable (like iteration).
However, the major difference is following considering below example.
IQueryable<PersonalDetail> list = db.PersonalDetails.Where(p => p.AutoId == 10);
IEnumerable<PersonalDetail> IIlist = db.PersonalDetails.Where(p => p.AutoId == 10);
In case of IQueryable, the sql statement is made to get only one record from database where AutoId is 10.
In case of IEnuerable, the sql statement is made to get all records from the database and then filter where AutoId is 10.
This gives us following conclusion.
1. IQueryable is good when you are retrieving and filtering the remote data such as getting data from database, web services etc. where as IEnuerable is good to get the data from in-memory data such as list or array that is created from C# code.
2. Both are readonly and forward only however IQueryable exists into System.Linq namespace but IEnuerable exists into System.Collections namespace.
3. IQueryable is used mainly when we need to LINQ to SQL or we need to work with any database objects with LINQ, IEnuerable is used where there is collection is enumeration is required.
I hope this helps.
ThanksSwappy_Gaj, if this helps please login to Mark As Answer. | Alert Moderator