Understand your C# queries! IEnumerable & IQueryable in explained

🔥 Learn the difference between IEnumerable and IQueryable! It is this EASY!
🚀 C# Progress Academy - Become a job-ready C# and Angular web developer to land your dream developer role: bit.ly/45vbPUg
Syncfusion Document Processing Library: syncf.co/3E0oCDw
Syncfusion ASP.NET Core Components: syncf.co/3roV8aE
We'll make sure to make a Developer out of you in no time!
So, what is C#?
C# (pronounced "See Sharp") is a modern, object-oriented, and type-safe programming language. C# enables developers to build many types of secure and robust applications that run in .NET. C# has its roots in the C family of languages and will be immediately familiar to C, C++, Java, and JavaScript programmers. This tour provides an overview of the major components of the language in C# 8 and earlier. If you want to explore the language through interactive examples, try the introduction to C# tutorials.
And what is IEnumerable?
Exposes an enumerator, which supports a simple iteration over a non-generic collection.
IEnumerable is the base interface for all non-generic collections that can be enumerated. For the generic version of this interface see System.Collections.Generic.IEnumerable. IEnumerable contains a single method, GetEnumerator, which returns an IEnumerator. IEnumerator provides the ability to iterate through the collection by exposing a Current property and MoveNext and Reset methods.
And what is IQueryable?
Provides functionality to evaluate queries against a specific data source wherein the type of the data is not specified.
The IQueryable interface is intended for implementation by query providers. It is only supposed to be implemented by providers that also implement IQueryable. If the provider does not also implement IQueryable, the standard query operators cannot be used on the provider's data source.
To learn more, make sure to watch the video, and we promise you that you'll become a C# developer by the end of the course! Have fun!
#csharp #coding #tutorial #learn #microsoft #net #I
TAGS
Tutorials,Tutorial,Programming,Course,Learn,Step by step,guide,development,programmer,video course,video tutorial,learn how to,how to,visual studio,c#,.net,.net core,dotnet,visual studio 2019,core,code,asp,asp net,c sharp,ienumerable,iqueryable,coding,linq,entity framework,entity framework core,csharp,iqueryable vs ienumerable,c# ienumerable vs iqueryable,iqueryable .net core,csharp interview,iqueryable vs ienumerable c#,ienumerable vs iqueryable c#
tutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.
Stay tuned and subscribe to tutorialsEU: goo.gl/rBFh3x
C#: / @tutorialseuc
Facebook: / tutorialseu-1093802040...
LinkedIn: / tutorialseu
Discord: / discord

Пікірлер: 52

  • @tutorialsEUC
    @tutorialsEUC Жыл бұрын

    🚀 C# Progress Academy - Become a job-ready C# and Angular web developer to land your dream developer role: bit.ly/45vbPUg

  • @HikingUtah
    @HikingUtah8 ай бұрын

    IEnumerable is an interface. So in your examples, the IEnumerable also has 0 items--just like IQueryable. It's just an interface that you can use to iterate over the list of items (currently stored in your original List). And you don't get the items until you iterate the collection.

  • @Marfig
    @Marfig10 ай бұрын

    Let's be clear here, the only reason why your example worked was that you decided to split the IEnumerable into two separate queries. Had you used the Where() extension method in the declaration of your enumerable object, and you would also have only returned 2500 customers through the network. In your example, there's actually no advantage in using one over the other. I think you can make a better video explaining the differences between IQueryable and IEnumerable if you focus on its actual benefits: With IQueryable, you can more easily compose queries dynamically based on runtime conditions. And you should avoid examples where you use IQueryable outside your ORM layer, unless you make it clear that doing so is actually not going to allow you to easily replace your ORM in the future.

  • @fibs9456
    @fibs9456 Жыл бұрын

    It's a little bit misleading that your example is using an in-memory list. This does not show the true benefit of iqueryable since ienumerable is evaluated lazy as well.

  • @tutorialsEUC

    @tutorialsEUC

    Жыл бұрын

    Hi, true but that's why I said that the list is only to get any kind of data and best to ignore :) Got your point anyway!

  • @fibs9456

    @fibs9456

    Жыл бұрын

    @@tutorialsEUC true that. I just was confused at the beginning because often watch this kind of video without audio. Nice video btw. Cheers

  • @patsornleuangsupornpong9819

    @patsornleuangsupornpong9819

    Жыл бұрын

    @@tutorialsEUCI got the whole point in the video but what do you mean by this? Can you explain a bit more? What is evaluated lazy?

  • @OOpSjm

    @OOpSjm

    Жыл бұрын

    @@patsornleuangsupornpong9819 look up "lazy loading"

  • @felixpollan
    @felixpollan7 ай бұрын

    5:18 "... IEnumerable is a real collection, it contains all the data..." is definitely wrong, the data are in the list behind the IEnumerable, the IEnumerable itself could be implemented without having any data underneath, the only limitation is that you can use IEnumerable just to move forward. So this is not a good answer in an interview, trust me!

  • @GuildOfCalamity
    @GuildOfCalamity Жыл бұрын

    Nice video! Would like to see more like this. For your tutorials I would highly recommend enabling "Display inline type hints" and "Display inline parameter name hints" in your VS options so that your viewers can see what the var types are resolving to.

  • @johncassidy3071
    @johncassidy307123 күн бұрын

    Am IEnumerable is often implemented as a coroutine that just promises to get you another element of you're willing to stick around for it. And if you stick around, you'll get them all.

  • @tangomoocow
    @tangomoocowАй бұрын

    Great explanation!

  • @8ytan
    @8ytan Жыл бұрын

    Some of what you said is only true because you chose a list to back the IEnumerable. An IEnumerable doesn't have to be "real" data, e.g. you can make an IEnumerable that is infinitely large.

  • @higherpurpose1212
    @higherpurpose12124 ай бұрын

    Man, I wish I knew this 10 years ago! It's an eye opener for me, thank you! I will check all your tutorials and subscribe!

  • @TkrZ
    @TkrZ Жыл бұрын

    No benchmarks?

  • @EMWMIKE
    @EMWMIKE Жыл бұрын

    the Ienumerable can be better if the sql don't have an index of revenue field. So sometimes it is actually better to do a bigger query and then filter from memory. Have happened to me a lot of times and implementing new indexes in big transaction tables in production is not easy. So before filtering sql stuff, do your index homework 😀 Good video !!

  • @billyarredondopucp
    @billyarredondopucp Жыл бұрын

    Finally, I got it. Thank you so much!

  • @eugenevv
    @eugenevv Жыл бұрын

    Thank you for an amazing and easy explanation!

  • @billymartin6497
    @billymartin64974 ай бұрын

    Would this be good for something like an auto complete, or would it be faster to just get the entire list first?

  • @ivanvincent7534
    @ivanvincent75345 ай бұрын

    The in memory List negatively effects the example. Setting this up with EFCore would place IQueryable and IEumerable in the correct context.

  • @simonroyjonesuk
    @simonroyjonesuk Жыл бұрын

    So helpful. Thanks a lot

  • @user-ue4if1of5c
    @user-ue4if1of5c9 ай бұрын

    Great explanation 👌

  • @Fkn1405
    @Fkn14053 ай бұрын

    very well explained! Thank U!

  • @pkmx-um9vb
    @pkmx-um9vb2 ай бұрын

    Really great explanation ... many thanks!

  • @odeyjoshuasunday998
    @odeyjoshuasunday9987 ай бұрын

    beautiful, i enjoyed it...simple differences between the two

  • @jannickbreunis
    @jannickbreunis Жыл бұрын

    Hello Jannick! Good video, although I have to search how to retrieve/create a IQuerable with my DataAcces and sql.

  • @tutorialsEUC

    @tutorialsEUC

    Жыл бұрын

    Great suggestion!

  • @fahreddinartuklu2620
    @fahreddinartuklu262010 ай бұрын

    thank you bro i understand it and i think there is no missing part. :)

  • @howto8709
    @howto870911 ай бұрын

    Nice video understood totally.

  • @ferenc3460
    @ferenc3460 Жыл бұрын

    Great! Now I know the difference but what is the benefit of Ienumerable then? Or when I work with DB should I always use queryable?

  • @tutorialsEUC

    @tutorialsEUC

    Жыл бұрын

    The benefit is that IEnumerable is a collection (like a list or an array) and you can iterate over the elements. The queryable is no collection. Benefit is the wrong termination here :) Greets!

  • @murtazachaudhary7262
    @murtazachaudhary7262 Жыл бұрын

    Very well explained, using it from long time, but donot know the differences 😢

  • @attilaguba856
    @attilaguba856 Жыл бұрын

    Thanks very much! Nice one! So basically it's better to use IQueryable to filter data instead IEnumarble!?

  • @tutorialsEUC

    @tutorialsEUC

    Жыл бұрын

    Yes, exactly

  • @ygtandoh

    @ygtandoh

    Жыл бұрын

    Also once u apply a toList() or toArray() to an iQueryable it becomes an iEnumerable

  • @KBHASKAR-
    @KBHASKAR-6 ай бұрын

    Thanks bro for vedios

  • @tusharparmar7142
    @tusharparmar7142 Жыл бұрын

    Thanks for sharing. Good content.

  • @tutorialsEUC

    @tutorialsEUC

    Жыл бұрын

    Thanks for watching!

  • @ma-arufburad8826
    @ma-arufburad882611 ай бұрын

    Well explained.

  • @chellaack1644
    @chellaack1644 Жыл бұрын

    Awesome

  • @khabbazz89
    @khabbazz89 Жыл бұрын

    nice work

  • @tutorialsEUC

    @tutorialsEUC

    Жыл бұрын

    Thank you! Cheers!

  • @user-qo7yb2hl3q
    @user-qo7yb2hl3q7 ай бұрын

    easy explanation!

  • @housamalamour7888
    @housamalamour7888 Жыл бұрын

    Fantastic Explanation, very clear and easy to understand. Keep it up man!

  • @tutorialsEUC

    @tutorialsEUC

    Жыл бұрын

    Glad you liked it!

  • @marcelomilbradt6562
    @marcelomilbradt65628 ай бұрын

    This video just wrong; both IQueryable and IEnumerable will only execute the code when you iterate through the collection. Both implementations have the same impact on the database since the code is converted to SQL when using a ORM. Also, how can you claim that ICollection is faster without providing any data or benchmarks?

  • @ieminu1875
    @ieminu18759 ай бұрын

    * support comment *

  • @Turko77777
    @Turko7777710 ай бұрын

    IEnumerable is NOT a real collection

  • @gedwistle1974
    @gedwistle19744 ай бұрын

    What you're saying about IEnumerable being an actual collection with data vs IQueryable not having data, is just WRONG. IEnumerable is just an Interface, IQueryable actually implements IEnumerable! All IQueryable instances are already IEnumerables.

  • @Telee_Pawt
    @Telee_Pawt6 ай бұрын

    Does anybody actually know what is going on with this stuff? We see heaps of examples everywhere but no informationon how anything actually works. Typical "aah" moment to be dashed again below by opposing views.