C# Linq: Why I Hate That I’m Loving It

Is this a silver-bullet? Yes… and no.

Mina Pêcheux
CodeX
Published in
7 min readAug 25, 2024

--

Photo by Jonas Gerlach on Unsplash

When we have a big C# project, we soon start to juggle around with lots of data. This data can come from various sources: it can be handwritten by the devs, extracted from a database, retrieved from an online URL… Because all of these sources might have different conventions, you might end up with some widely estranged data formats.

Now, say you want to read through this list of countries you fetched on the net, filtering by continent; or you want to get all the products in your PostgreSQL DB that have a name starting with “Tom”; or you want to get the static variable your peers wrote to define the application settings and check if any of those settings are null.

At first glance, it looks like those tasks are frustratingly hard to regroup into similar processes. Since the data is not shaped the same, surely, it’s going to be impossible to have a standardised exploration of it, right?

Well that’s exactly the kind of situations where you can use a super cool C# tool: Linq! So, today, let’s have a look at this system and see how it can help us simplify data fetching or transform data from one format to another :)

Enter the Language Integrated Query (LINQ)

--

--

Mina Pêcheux
CodeX
Writer for

I’m a freelance full-stack web & game developer. I’m passionate about topics like CGI, music, data science and more! Find me at: https://minapecheux.com :)