Skip to main content

Posts

Showing posts with the label Linq

Evolution of LINQ in C#: A Journey Through Powerful Data Queries

Since its debut in C# 3.0, Language-Integrated Query (LINQ) has reshaped the way C# developers handle data. LINQ allows seamless querying across various data sources like collections, databases, and XML, directly within C#. With each C# release, LINQ has been enhanced to bring more power and flexibility to developers. This blog explores the new methods and capabilities added in each version, demonstrating how LINQ has evolved to meet the demands of modern applications. What is LINQ? LINQ (Language-Integrated Query) is a set of powerful query capabilities embedded into C# that enable developers to interact with data in a SQL-like syntax. By providing direct access to query operations such as filtering, sorting, grouping, and projecting, LINQ simplifies data manipulation, making code more readable and expressive. The LINQ Journey: From C# 3.0 to C# 10.0 Let’s embark on a journey to see how LINQ has grown over the years, with each version bringing new tools that make data handling more ...

C# : Most used operations in LINQ

Language-Integrated Query (LINQ) is a powerful feature in C# that enables developers to query and manipulate data using a syntax similar to SQL. LINQ makes code more expressive, readable, and less error-prone. In this blog post, we'll explore some common LINQ operations using concise C# code snippets. Filtering Data with Where List < int > numbers = new List < int > { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; var evenNumbers = numbers . Where ( n => n % 2 == 0 ) ; Here, Where filters the elements of the collection based on a specified condition, returning only the even numbers. Projecting Data with Select List < string > names = new List < string > { "Alice" , "Bob" , "Charlie" , "David" } ; var nameLengths = names . Select ( name => name . Length ) ; The Select operation projects each element of the collection into a new form. In this case, it returns the lengths of the names. Sorti...