filmov
tv
Must Watch 7 LINQ C# best practices in ASP.NET Core MVC (2 Minutes Quick Tips)
Показать описание
In this video, I'll be sharing 7 essential LINQ best practices that every ASP.NET Core MVC developer should know. What is LINQ? LINQ stands for Language Integrated Query. It enables us to build queries in C# to retrieve and manipulate data from a variety of data sources, including databases, collections, XML, and others. It is beneficial to use LINQ since it can make our code more readable and concise; but it’s important to use it effectively to avoid common pitfalls that can slow down our application or make our code harder to maintain. So, in this video, I'll cover 7 best practices for writing LINQ queries. Whether you’re just getting started with LINQ or looking to refine your skills, these tips will help you write cleaner, more efficient code and avoid common pitfalls. We'll dive into examples that showcase how to optimize your queries, avoid performance issues, and make your code more readable and maintainable. Don't miss out on these crucial insights that can take your LINQ skills to the next level!
Note: Last code example is wrong. The Find() method cannot be used after applying AsNoTracking() in Entity Framework Core. The correct code should be .AsNoTracking().FirstOrDefault();
All my full source code:
Suggest what projects would you like to download next:
Thank you!
Timestamp:
0:00 Tip 1- Count vs Any
0:28 Tip 2- Where vs FirstOrDefault
0:44 Tip 3- ToList
1:10 Tip 4- Where and Select
1:31 Tip 5- Outside the loop
2:00 Tip 6- Select what's necessary
2:21 Tip 7- AsNoTracking
Other videos:
Note: Last code example is wrong. The Find() method cannot be used after applying AsNoTracking() in Entity Framework Core. The correct code should be .AsNoTracking().FirstOrDefault();
All my full source code:
Suggest what projects would you like to download next:
Thank you!
Timestamp:
0:00 Tip 1- Count vs Any
0:28 Tip 2- Where vs FirstOrDefault
0:44 Tip 3- ToList
1:10 Tip 4- Where and Select
1:31 Tip 5- Outside the loop
2:00 Tip 6- Select what's necessary
2:21 Tip 7- AsNoTracking
Other videos: