DEV Community

Cover image for What Is LINQ?
Hasan Elsherbiny
Hasan Elsherbiny

Posted on

8 7 8 9 9

What Is LINQ?

LINQ Stands for : Language Integrated Query and it was made to allow users perform queries written with C# to Data source.

when your data source is Memory List : This Is Called LINQ To Object

when your data source is XML File : This Is Called LINQ To XML

when your data source is SQL Database : This Is Called LINQ To SQL
in this case your query is being translated into SQL query and performed against configured database.

LINQ To SQL has been evolved to more complicated ORM and now it's a part of Entity framework where your database tables are mapped into C# entitles and with the help of LINQ to SQL you can perform queries and commands

There are two styles to write LINQ Queries

  1. Query Like Style
    from myVariable in mysource select myVariable
    in this example you are select from your data source "mysource" and having a pointer called myVariable can be used to access properties of object of your data source.

  2. Extension Methods using lamda expression

mysource.Select(myVariable => myVariable)
this is the same impact of the first example but with another code style.

API Trace View

Struggling with slow API calls? πŸ•’

Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more β†’

Top comments (4)

Collapse
 
raddevus profile image
raddevus β€’

Hey, did you know about the free software developer's scratchpad which lets you write complete .NET programs and run all your LINQ? You can get it FREE at linqpad.net/
I'm not affiliated with linqpad at all, but I've been using it for 15 years or so.

It was actually created by the authors of the book, C# In A Nutshell (which is really the definitive guide for learning C#.

Image description
If you get a chance, would you mind reading my latest article here on dev.to? Software Developer, Are You Just A Hammer?

Collapse
 
hasanelsherbiny profile image
Hasan Elsherbiny β€’

thanks for letting me know that

Collapse
 
lindiwethabo profile image
Lindiwe Thabo β€’

This LINQ article is an absolute gem! 🌟 As a total newbie to C# and LINQ, I can't thank you enough for breaking it down in such a newbie-friendly way. 🀩 Seriously, I was feeling so overwhelmed, but your explanations and examples totally saved the day! πŸ™

I mean, who knew LINQ could be this cool and powerful? πŸ’ͺ Your step-by-step guide had me nodding my head like 'Oh, that makes so much sense now! πŸ˜…' I'm feeling like a LINQ ninja already! πŸ±β€πŸ‘€

You've got a knack for teaching, I must say! πŸ‘ Your writing style is so clear and easy to follow, even for someone as green as me in the coding world. Can't wait to dive into more LINQ magic with this newfound confidence. ✨

Thanks a ton for sharing your wisdom with us newbies! You're like the LINQ guru we all needed in our lives. πŸ§™β€β™€οΈ I'm saving this article for future reference and sharing it with my coding buddies who are also just starting out. Spread the LINQ love! πŸ’•

Collapse
 
hasanelsherbiny profile image
Hasan Elsherbiny β€’

thanks a lot

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs