After reading "What is the Java equivalent of LINQ?", I'd like to know, is (lowercase) language-integrated query - in other words the ability to use a concise syntax for performing queries over object collections or external stores - going to be the path of the future for most general purpose languages? Or is LINQ an interesting piece of technology that will remain confined to Microsoft languages? Something in between?
EDIT: I don't know other languages, but as I am learning it seems like LINQ is neither unprecedented nor unique. The ideas in LINQ - lambdas and queries - are present in other languages, and the ideas seem to be spreading.
Readable code: LINQ makes the code more readable so other developers can easily understand and maintain it. Standardized way of querying multiple data sources: The same LINQ syntax can be used to query multiple data sources. Compile time safety of queries: It provides type checking of objects at compile time.
Linq namespace. LINQ provides us common query syntax which allows us to query the data from various data sources. That means using a single query we can get or set the data from various data sources such as SQL Server database, XML documents, Datasets, and any other in memory objects such as Collections, Generics, etc.
Language-Integrated Query (LINQ) is the name for a set of technologies based on the integration of query capabilities directly into the C# language. Traditionally, queries against data are expressed as simple strings without type checking at compile time or IntelliSense support.
LINQ to Entities provides Language-Integrated Query (LINQ) support that enables developers to write queries against the Entity Framework conceptual model using Visual Basic or Visual C#. Queries against the Entity Framework are represented by command tree queries, which execute against the object context.
Before LinQ, Python had Generator Expressions which are specific syntax for performing queries over collections. Python's syntax is more reduced than Linq's, but let you basically perform the same queries as easy as in linq. Months ago, I wrote a blog post comparing queries in C# and Python, here is a small example:
C# Linq:
var orders = from c in customers
where c.Region == "WA"
from o in c.Orders
where o.OrderDate >= cutoffDate
select new {c.CustomerID, o.OrderID};
Python Generator Expressions:
orders = ( (c.customer_id, o.order_id)
for c in customers if c.region == 'WA'
for o in c.orders if o.date >= cutoff_date)
Syntax for queries in programming languages are an extremely useful tool. I believe every language should include something like that.
After spending years
It was about time somone made an easy to access and language integrated way to talk to a database. LINQ to SQL should have been made years ago. I applaud the team that come up with it - finally a database access framework that makes sense.
It's not perfect, yet, and my main headache at the moment is there's no real support for LINQ2SQL for other common databases, nor are there anything like it for Java.
(LINQ in general is nice too btw, not just LINQ to SQL :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With