Understand your C# queries! IEnumerable & IQueryable in explained

  Рет қаралды 30,038

tutorialsEU - C#

tutorialsEU - C#

Жыл бұрын

🔥 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
@HikingUtah 8 ай бұрын
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
@Marfig 10 ай бұрын
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"
@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.
@felixpollan
@felixpollan 8 ай бұрын
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!
@higherpurpose1212
@higherpurpose1212 4 ай бұрын
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!
@johncassidy3071
@johncassidy3071 Ай бұрын
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.
@eugenevv
@eugenevv Жыл бұрын
Thank you for an amazing and easy explanation!
@billyarredondopucp
@billyarredondopucp Жыл бұрын
Finally, I got it. Thank you so much!
@simonroyjonesuk
@simonroyjonesuk Жыл бұрын
So helpful. Thanks a lot
@Fkn1405
@Fkn1405 3 ай бұрын
very well explained! Thank U!
@billymartin6497
@billymartin6497 5 ай бұрын
Would this be good for something like an auto complete, or would it be faster to just get the entire list first?
@pkmx-um9vb
@pkmx-um9vb 2 ай бұрын
Really great explanation ... many thanks!
@howto8709
@howto8709 11 ай бұрын
Nice video understood totally.
@fahreddinartuklu2620
@fahreddinartuklu2620 10 ай бұрын
thank you bro i understand it and i think there is no missing part. :)
@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.
@odeyjoshuasunday998
@odeyjoshuasunday998 7 ай бұрын
beautiful, i enjoyed it...simple differences between the two
@TkrZ
@TkrZ Жыл бұрын
No benchmarks?
@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!
@user-ue4if1of5c
@user-ue4if1of5c 9 ай бұрын
Great explanation 👌
@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 !!
@tangomoocow
@tangomoocow Ай бұрын
Great explanation!
@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!
@tusharparmar7142
@tusharparmar7142 Жыл бұрын
Thanks for sharing. Good content.
@tutorialsEUC
@tutorialsEUC Жыл бұрын
Thanks for watching!
@KBHASKAR-
@KBHASKAR- 7 ай бұрын
Thanks bro for vedios
@ma-arufburad8826
@ma-arufburad8826 11 ай бұрын
Well explained.
@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
@murtazachaudhary7262
@murtazachaudhary7262 Жыл бұрын
Very well explained, using it from long time, but donot know the differences 😢
@housamalamour7888
@housamalamour7888 Жыл бұрын
Fantastic Explanation, very clear and easy to understand. Keep it up man!
@tutorialsEUC
@tutorialsEUC Жыл бұрын
Glad you liked it!
@ivanvincent7534
@ivanvincent7534 5 ай бұрын
The in memory List negatively effects the example. Setting this up with EFCore would place IQueryable and IEumerable in the correct context.
@chellaack1644
@chellaack1644 Жыл бұрын
Awesome
@khabbazz89
@khabbazz89 Жыл бұрын
nice work
@tutorialsEUC
@tutorialsEUC Жыл бұрын
Thank you! Cheers!
@user-qo7yb2hl3q
@user-qo7yb2hl3q 8 ай бұрын
easy explanation!
@marcelomilbradt6562
@marcelomilbradt6562 8 ай бұрын
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
@ieminu1875 9 ай бұрын
* support comment *
@gedwistle1974
@gedwistle1974 4 ай бұрын
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_Pawt 7 ай бұрын
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.
@Turko77777
@Turko77777 11 ай бұрын
IEnumerable is NOT a real collection
CREATE and CONNECT DATABASES in ASP.NET
18:11
tutorialsEU - C#
Рет қаралды 44 М.
IEnumerable 🆚 IEnumerator Interfaces in C#
34:06
tutorialsEU
Рет қаралды 27 М.
Каха инструкция по шашлыку
01:00
К-Media
Рет қаралды 8 МЛН
Each found a feeling.#Short #Officer Rabbit #angel
00:17
兔子警官
Рет қаралды 6 МЛН
Which one is the best? #katebrush #shorts
00:12
Kate Brush
Рет қаралды 19 МЛН
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,1 МЛН
How IEnumerable can kill your performance in C#
11:02
Nick Chapsas
Рет қаралды 112 М.
Beginner CRASH COURSE for IEnumerable in .NET C#
14:13
Dev Leader
Рет қаралды 4,9 М.
Top 30  .Net Core Interview Questions in 30 mins - .NET C#
37:11
Interview Happy
Рет қаралды 287 М.
Explain IEnumerable in C# ( C# Interview Questions)
8:40
Questpond
Рет қаралды 42 М.
8 await async mistakes that you SHOULD avoid in .NET
21:13
Nick Chapsas
Рет қаралды 308 М.
how Google writes gorgeous C++
7:40
Low Level Learning
Рет қаралды 784 М.
Каха инструкция по шашлыку
01:00
К-Media
Рет қаралды 8 МЛН