When to use IEnumerable vs IQueryable?
Вставка
- Опубліковано 15 жов 2024
- A common interview question with .NET and EF Core is explain the difference between IEnumerable and IQueryable?
We use them so often that many times we forget the basic difference on which will help optimization in which scenario.
In this short video we will quickly cover these topics.
Full Course on Entity Framework Core : www.dotnetmast...
3:58 "if we want to apply filter in memory, IEnumerable is preferred". But I get the overall lesson. Excellent job and I will definitely use this as my in depth explanations in .NET interviews. Thank you so much Sir.:)
Most simplest explanation that I found today thank you so much 😊
Thank you! After reading several books on C#, I found this explanation to be the best of them all!
You are the best teacher on the earth, thank you, Bhrugen.
I love your courses on the Udemy as well..
Usefule video. I just want to add one small point here, when you directly query on the DbSet (instead of converting it to IEnumrable) using Where lambda expression and pass on the filter condition, it will generate propert T-SQL statement with condition applied at the database level itself.
Dude your explaining is out of this world. Thank you
thank you for the comment! :)
@@DotNetMastery but why when we use inline query,and even explicitly write return type as IEnumerable,it will generate as IQueryable?Is it only specific use case like in video?that is using 2 lines query.
Awesome explanation. Thank you.
Thanks for the explanation. Please share more of this kind of topic. eg: ICollection vs IEnumerable vs List
coming up next week my friend.
Now I understand why Iqueryable is used in Bulkybook project interface. This is just perfect
Like the Bite size content. Videos on EF & LINQ performance related topics would be great.
Excellent explanation
Very clear explaination .. I have a question .. How do you study ? and What resources do you study from ?
To the point... Awesome!!!
thank you so much
In 3:57 I think you meant to say "IEnumerable" as the filtering will happen in the memory
You are 100% correct! My bad there.
@dotnetmastery so basically, they are both interfaces that the type List implements, but by using either of them you defer execution in a database query. IEnumerable will read in the full dataset when you iterate or .ToList() it even if you have Where clauses in your linq or lamdba expression but IQueryable will actually apply any filtering at source, i.e send the where clause in with the first statement.
List does not implement IQueryable
Good one.
Excellent. Thanks very much.
Nice one.
Thanks dude, it really helps to save a lot of time
Also Do you have Entity Framework Course ?
thanks, very helpful
Got you! thanks!
Great explanation. Thanks.
Excellent 🎉
Excellent video, but why IEnumerable is retrieving all the records on initial call to Db if it has deferred execution? I would have thought that only when applying the filtering, on the second line, it would make the call to Db.
I think they both technically have deferred execution, in that only when you iterate through the result will it actually fire the database query, its just that IQueryable will send the query with the where clause and therefore filter at source
Thanks
Is it safe to say one of the few use cases of Ienumerable would be testing the accuracy of Iqueryable logic?
Thanks for the content. Please explain IEnumerable vs List also
List implements IEnumerable
coming up next week!
Interesting.
Thank you, champ!
Thank you
Thank you dear for your explanation but you may mean IEnumerable instead of IQueryable in min 3:56
Very interesting
thanks so much
Hi, it's nice. Request you to upload a video on differences between .Net Framework, .Net Core, .Net 6, ASP.NET Framework, Entity framework... I know but not getting the exact difference.. please an explanation would be highly appreciated.
Summary - user Ienumerable when you want to filter your inmemory data i.e. datas which is in your RAM, not in database,(List,Dtos, etc). User iqueryable when you wnt to filter datas which is already in database.
I have check with profiler my friend. But this expanation is WRONG. IEnumerable (ToList()), still where clause is applied
Plz create dotnet core web api with all the concepts for a beginner.
thank you