LINQ stands for Language Integrated Query Language. It was a feature introduced along with Visual Studio 2008 that extends the querying capabilities of C# for any sort of data source. Generally LINQ is used to query data sources like SQL Server Databases and XML files. I use it to query databases.
I'm not going to explain everything about LINQ here. I'm going to just talk about some very basic details.
LINQ can be written in two very different ways, syntactically.
I have run into trouble using LINQ when attempting to accomplish something that involved a GROUP BY expression. An SQL query that would take 250 ms was taking abnormally long, at least a minute when I expressed my intentions in LINQ incorrectly. I wasn't born with a LINQ spoon in my mouth. I'm just learning it now.
Apparently there are two types of LINQ expressions, LINQ-to-objects and LINQ-to-entities.
I know giving that link to those websites isn't helping you understanding quickly enough. So let me summarize them for you. The former acts on objects in memory. The latter forces action on the database layer. So if I were to write a complex group by query, I would want to make use of LINQ to entities because databases are the best place to group things up and not do it in memory as lists of objects.
That is just a very short summary. I'll let you decide what you want to do with LINQ.
And for learning LINQ:
I'm not going to explain everything about LINQ here. I'm going to just talk about some very basic details.
LINQ can be written in two very different ways, syntactically.
- An expression that looks more like a chain of methods formally knows as Lambda expression
- An expression that looks like a variant of SQL which could selectively be mixed with the Lambda syntax.
I have run into trouble using LINQ when attempting to accomplish something that involved a GROUP BY expression. An SQL query that would take 250 ms was taking abnormally long, at least a minute when I expressed my intentions in LINQ incorrectly. I wasn't born with a LINQ spoon in my mouth. I'm just learning it now.
Apparently there are two types of LINQ expressions, LINQ-to-objects and LINQ-to-entities.
I know giving that link to those websites isn't helping you understanding quickly enough. So let me summarize them for you. The former acts on objects in memory. The latter forces action on the database layer. So if I were to write a complex group by query, I would want to make use of LINQ to entities because databases are the best place to group things up and not do it in memory as lists of objects.
That is just a very short summary. I'll let you decide what you want to do with LINQ.
And for learning LINQ:
Learning LINQ
101 LINQ Examples is a great place
to start. So many samples that you will never finish checking out with code and explanation. It starts out with simple queries and then gets to the more challenging ones slowly.
A few other things
to check out might be :
If
you are looking for a tool to help work with LINQ, consider downloading LinqPad. This is an inevitable thing for an application developer working on a project that involves a lot of LINQ. Helps debugging and getting queries behave and obey. And there are more LINQ tutorials to handle some of the more advanced
features in there like Mastering
Linq.
Comments
Post a Comment