GitHub profile
.NET Framework .NET C# VB.NET LINQ ASP.NET Web API REST SignalR Windows Forms WPF WCF RabbitMQ PHP SQL Server MySQL PostgreSQL MariaDB SQLite MongoDB ADO.NET ORM Entity Framework Dapper XML JSON HTML5 CSS3 Bootstrap JavaScript jQuery Angular React TypeScript NPM Blazor UI/UX Responsive Web Design Redis Elasticsearch GraphQL Grafana Agile Scrum Kanban Windows Server IIS PowerShell Active Directory TFS Azure Automation Software Reverse Engineering Performance Optimization Git Jira/Confluence CI/CD TeamCity SOLID KISS DRY YAGNI
Always will be ready notify the world about expectations as easy as possible: job change page

Best LINQ performance

Created: May 16, 2022
Author: Hussein NM
Source: source
Views: 703

In this article, I will show the most performant way to write queries for a collection of objects in .Net Core. The article discusses the common methods of LINQ and their comparison. After reading this article, you may have to review your project code!

Comparisons were made between query syntax, called LINQ, and method syntax called LAMBDA.

💡 Connect with me on LinkedIn:

✨ Where()

LINQ_Where (Method name):


🚀 Performance

Which one do you think is faster?

In this simple performance query, both methods are similar.

✨ Any()




🚀 Performance

Using Any() as the LAMBDA_Any method is faster.

✨ First()




🚀 Performance

Using First() as the method a LAMBDA call is faster.

✨ FirstOrDefault()




🚀 Performance

Using FirstOrDefault() as the method a LAMBDA call is faster.

✨ Last()




🚀 Performance

Using Last() as the method a LAMBDA call is faster.

✨ LastOrDefault()




🚀 Performance

Using LastOrDefault() as the method a LAMBDA call is faster.


As shown in this article, you should always use Any(), First(), FirstOrDefault(), Last(), LastOrDefault, or Where() at the beginning of a LAMBDA statement.

May 14, 2023
Author: Edwin Klesman
In this article, I’ll show you what the basic steps are for converting a SQL query into LINQ. You’ll learn the basic steps needed while we convert an example query.In this article, it's assumed that you have a basic understanding...
Nov 19, 2020
Author: Ryszard Seniuta
Although SQL Server's Full-Text search is good for searching text that is within a database, there are better ways of implementing search if the text is less-well structured, or comes from a wide variety of sources or formats. Ryszard takes...
Jul 11, 2021
Author: Sasha Mathews
In C#, reference types can be assigned null values. This is something that developers will have to live with until they use classes to create software. Unfortunately, the folks at Microsoft cannot simply disallow null assignment to reference variables at...
Aug 15, 2021
.NET has a large number of built in exceptions. However, there maybe times when none of the built exceptions seem adequate for your particular scenario and you will need to create your own custom (AKA “user defined”) exception.This post focuses...
Send message
Your name

© 1999–2023 WebDynamics
1980–... Sergey Drozdov
Area of interests: .NET | .NET Core | C# | ASP.NET | Windows Forms | WPF | Windows Phone | HTML5 | CSS3 | jQuery | AJAX | MS SQL Server | Transact-SQL | ADO.NET | Entity Framework | IIS | OOP | OOA | OOD | WCF | WPF | MSMQ | MVC | MVP | MVVM | Design Patterns | Enterprise Architecture | Scrum | Kanban