The source code of the video: github.com/TuralSuleymani/DecodeBytes/tree/tutorial/masterCsharpDelegatesLikeSenior PS: In this particular example, I was focusing on demonstrating a specific concept, and I opted for the simpler 'foreach' syntax for brevity. The repo contains materialization for Cards. By materializing results first, you ensure: 1. Only a single database query is executed, improving performance and predictability. 2. You have a concrete collection of entities in memory for iteration. 3. Each iteration of the foreach loop potentially triggers a separate database query to fetch the next entity if you use dbset with foreach.
hey brother im a junior developer from Spain and i want to thank you for all youre doing for us, its the first time that i really can understand how delegates work in a real world context and not just learning how to write a func or predicate but really understanding when and why i should do it. Thanks a lot!
Hey man, Thanks a lot. I'm really happy that you if was helpful. I'll continue to create such type of understandable content. Thank you again for your comment. You made my day!
This is the most efficient way to learn something, in my opinion. When we're presented with the problems we need to solve, it helps us understand why we're using certain concepts. You're a great teacher!❤
Thank you so much for your kind words! 😊 I'm really glad to hear that you find this approach helpful. Solving real problems is definitely the best way to learn and understand concepts more deeply. Keep up the great work! 💪
You're very welcome! I'm glad my explanation was helpful and insightful. It's always rewarding to know I've contributed to someone's understanding of a complex topic
That's awesome to hear,! I put a lot of effort into these videos, and it's great to know they're paying off. I'm always working on new content, so be sure to subscribe to stay updated on the latest releases.
Senior Developer using a foreach on an DbSet/IQueryable is a bit odd. I understand it isn't the focus of the video, but especially in teaching content, I always try to use best practices in all contained code to avoid confusion down the line.
Thanks for pointing this out! I always appreciate feedback that helps me ensure my content aligns with best practices. You're absolutely right that using foreach on a DbSet or IQueryable can have potential implications, and I should have been more mindful of that in the video. In this particular case, I was focusing on demonstrating a specific concept, and I opted for the simpler foreach syntax for brevity. Added DbSet materialization to the branch
I can understand why your example it's not liked by @IGODX. You are enumerating a DBSet, in a real world scenario it can cause major issues. Would have been better if your example had been based on a simple collection rather than a DBSet.
Good catch! Thank you for your comment! Actually the purpose was explaning and focusing to delegates rather than DbSet usage. Definitely I'll take it into account in my future videos.
20:46 using ConsoleApp1; var cards = GetCardsByDelegate(3, new CustomerDelegate(cutomerId => cutomerId < 4)); // Lambda cards.ForEach(card => Console.WriteLine(card)); Console.ReadKey(); static List GetCardsByDelegate(int customerId, CustomerDelegate customerDelegate) // Delegate { var cards = new List(); using var dbcontext = new CustomerAppDbContext(); var query = from card in dbcontext.Cards // LINQ where customerDelegate(card.CustomerId) select card; cards.AddRange(query.ToList()); return cards; } // Delegates public delegate bool CustomerDelegate(int customerId);
Hi @kvelez, thank you for your comment. Definitely, using 'customerId' from the argument is another implementation that fits especially for your LINQ method implementation.
The source code of the video: github.com/TuralSuleymani/DecodeBytes/tree/tutorial/masterCsharpDelegatesLikeSenior
PS: In this particular example, I was focusing on demonstrating a specific concept, and I opted for the simpler 'foreach' syntax for brevity. The repo contains materialization for Cards.
By materializing results first, you ensure:
1. Only a single database query is executed, improving performance and predictability.
2. You have a concrete collection of entities in memory for iteration.
3. Each iteration of the foreach loop potentially triggers a separate database query to fetch the next entity if you use dbset with foreach.
hey brother im a junior developer from Spain and i want to thank you for all youre doing for us, its the first time that i really can understand how delegates work in a real world context and not just learning how to write a func or predicate but really understanding when and why i should do it. Thanks a lot!
Hey man, Thanks a lot. I'm really happy that you if was helpful. I'll continue to create such type of understandable content. Thank you again for your comment. You made my day!
This is the most efficient way to learn something, in my opinion. When we're presented with the problems we need to solve, it helps us understand why we're using certain concepts. You're a great teacher!❤
Thank you so much for your kind words! 😊 I'm really glad to hear that you find this approach helpful. Solving real problems is definitely the best way to learn and understand concepts more deeply. Keep up the great work! 💪
Smiles..this is 100% solid explanation. i like the way you explain some topics.....will definitely be watching this account hence forth. Thanks mate.
Awesome, thank you! Glad you liked it! Thanks for watching and subscribing!
Wonderful! I'm self-learning and don't quite understand delegate before, but now I can put it to work thanks to your explaination. Keep the good work.
That's great!
Really happy to hear that. Keep up the self-learning, it's a valuable skill.
FINALLY I UNDERSTOOD DELEGATES XD Thanks very much, very good video!
Glad to hear that! You're welcome! Thank you for subscribing!
Nobody explained these topics like you.
Thank you!
You're very welcome! I'm glad my explanation was helpful and insightful. It's always rewarding to know I've contributed to someone's understanding of a complex topic
Congratulations Tural. I'm proud of you ❤
Thank you @eldarzeynalov2703, really appreciate it! Hope you liked it
Very useful, thank you!
Glad it was helpful!
i tried learning haskell once before C#.
i found that delegates are like haskell typeclass.
Thanks for sharing! Haskell is also one of the interesting languages to learn
Mən özüm də proqramlaşdırmanı struktulu olaraq videodakı şəxsin dərslərilə öyrənməyə başlamışam. 👍
Thank you @TuralAsgarAZ, your support is really valuable. Thank you for spending the time to write a comment!
10/10 thank you!
That means a lot to me! Your support motivates me to keep creating.
Thx bro, that was a cool course. Im appreciates for your time that spent to recording vidoes. keep going to teaching more titles 👍
That's awesome to hear,! I put a lot of effort into these videos, and it's great to know they're paying off. I'm always working on new content, so be sure to subscribe to stay updated on the latest releases.
Senior Developer using a foreach on an DbSet/IQueryable is a bit odd. I understand it isn't the focus of the video, but especially in teaching content, I always try to use best practices in all contained code to avoid confusion down the line.
Thanks for pointing this out! I always appreciate feedback that helps me ensure my content aligns with best practices. You're absolutely right that using foreach on a DbSet or IQueryable can have potential implications, and I should have been more mindful of that in the video.
In this particular case, I was focusing on demonstrating a specific concept, and I opted for the simpler foreach syntax for brevity. Added DbSet materialization to the branch
Very nice. Amazing .. subscribed already..❤
"Thank you so much! I'm so glad you enjoyed the video. I really appreciate you subscribing!
I don't like the example that you used here
Thank you for your comment! I'd be happy to hear the reason for taking your feedback into account and to use better examples in the future.
I can understand why your example it's not liked by @IGODX. You are enumerating a DBSet, in a real world scenario it can cause major issues.
Would have been better if your example had been based on a simple collection rather than a DBSet.
Good catch! Thank you for your comment! Actually the purpose was explaning and focusing to delegates rather than DbSet usage. Definitely I'll take it into account in my future videos.
20:46
using ConsoleApp1;
var cards = GetCardsByDelegate(3, new CustomerDelegate(cutomerId => cutomerId < 4)); // Lambda
cards.ForEach(card => Console.WriteLine(card));
Console.ReadKey();
static List GetCardsByDelegate(int customerId, CustomerDelegate customerDelegate) // Delegate
{
var cards = new List();
using var dbcontext = new CustomerAppDbContext();
var query = from card in dbcontext.Cards // LINQ
where customerDelegate(card.CustomerId)
select card;
cards.AddRange(query.ToList());
return cards;
}
// Delegates
public delegate bool CustomerDelegate(int customerId);
Hi @kvelez, thank you for your comment. Definitely, using 'customerId' from the argument is another implementation that fits especially for your LINQ method implementation.