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...

КОМЕНТАРІ • 48

  • @sheikhmahmud7647
    @sheikhmahmud7647 8 місяців тому +8

    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.:)

  • @udithwiratunga9438
    @udithwiratunga9438 6 днів тому

    Most simplest explanation that I found today thank you so much 😊

  • @vladislav3105
    @vladislav3105 Рік тому +8

    Thank you! After reading several books on C#, I found this explanation to be the best of them all!

  • @mayter05
    @mayter05 11 місяців тому +3

    You are the best teacher on the earth, thank you, Bhrugen.
    I love your courses on the Udemy as well..

  • @prasadhonrao
    @prasadhonrao 8 місяців тому

    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.

  • @dedthepker
    @dedthepker Рік тому +1

    Dude your explaining is out of this world. Thank you

    • @DotNetMastery
      @DotNetMastery  Рік тому

      thank you for the comment! :)

    • @serg1778
      @serg1778 Рік тому

      @@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.

  • @reesebrandon4281
    @reesebrandon4281 Рік тому +2

    Awesome explanation. Thank you.

  • @sh2983
    @sh2983 2 роки тому +9

    Thanks for the explanation. Please share more of this kind of topic. eg: ICollection vs IEnumerable vs List

  • @obinnailoanya8730
    @obinnailoanya8730 2 роки тому

    Now I understand why Iqueryable is used in Bulkybook project interface. This is just perfect

  • @MAli-pu1ik
    @MAli-pu1ik 2 роки тому +1

    Like the Bite size content. Videos on EF & LINQ performance related topics would be great.

  • @knowledge4888
    @knowledge4888 Рік тому +1

    Excellent explanation

  • @ahmedalaa5142
    @ahmedalaa5142 4 місяці тому

    Very clear explaination .. I have a question .. How do you study ? and What resources do you study from ?

  • @shubhambahre9021
    @shubhambahre9021 Рік тому +2

    To the point... Awesome!!!

  • @mike-harvey
    @mike-harvey 2 роки тому +8

    In 3:57 I think you meant to say "IEnumerable" as the filtering will happen in the memory

  • @JohnOfChernarus
    @JohnOfChernarus Рік тому

    @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.

    • @joejjj4378
      @joejjj4378 10 місяців тому

      List does not implement IQueryable

  • @KaleemAbbas-vt4ho
    @KaleemAbbas-vt4ho 11 місяців тому

    Good one.

  • @williamraul8841
    @williamraul8841 6 місяців тому

    Excellent. Thanks very much.

  • @obinnaokafor6252
    @obinnaokafor6252 2 роки тому +1

    Nice one.

  • @algorithm-artisan
    @algorithm-artisan Рік тому

    Thanks dude, it really helps to save a lot of time

  • @ahmedalaa5142
    @ahmedalaa5142 4 місяці тому

    Also Do you have Entity Framework Course ?

  • @StephenBeale
    @StephenBeale Місяць тому

    thanks, very helpful

  • @vladshepeluk7442
    @vladshepeluk7442 Рік тому +1

    Got you! thanks!

  • @CarlosWashingtonMercado
    @CarlosWashingtonMercado 2 роки тому

    Great explanation. Thanks.

  • @ashishnayak2666
    @ashishnayak2666 Рік тому

    Excellent 🎉

  • @alvaromp1106
    @alvaromp1106 Рік тому +1

    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.

    • @JohnOfChernarus
      @JohnOfChernarus Рік тому

      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

  • @KBHASKAR-
    @KBHASKAR- Місяць тому

    Thanks

  • @drewwilson8756
    @drewwilson8756 Рік тому

    Is it safe to say one of the few use cases of Ienumerable would be testing the accuracy of Iqueryable logic?

  • @mike-harvey
    @mike-harvey 2 роки тому

    Thanks for the content. Please explain IEnumerable vs List also

  • @kvelez
    @kvelez 10 місяців тому

    Interesting.

  • @CodeBallast
    @CodeBallast Рік тому

    Thank you, champ!

  • @shabanelmogy7912
    @shabanelmogy7912 Рік тому

    Thank you

  • @hassanhemdan9180
    @hassanhemdan9180 Рік тому

    Thank you dear for your explanation but you may mean IEnumerable instead of IQueryable in min 3:56

  • @imanqoly
    @imanqoly 2 роки тому

    Very interesting

  • @luiscahuana310
    @luiscahuana310 Рік тому

    thanks so much

  • @shubhamkGupta
    @shubhamkGupta 2 роки тому

    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.

  • @watchtube9429
    @watchtube9429 2 місяці тому

    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.

  • @rizwanmallick8398
    @rizwanmallick8398 Рік тому

    I have check with profiler my friend. But this expanation is WRONG. IEnumerable (ToList()), still where clause is applied

  • @ecstasy3129
    @ecstasy3129 Рік тому

    Plz create dotnet core web api with all the concepts for a beginner.

  • @JacobAnnooz
    @JacobAnnooz Рік тому

    thank you