DEV Community

Cover image for What Is LINQ?
Hasan Elsherbiny
Hasan Elsherbiny

Posted on

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.

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