Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is linq different from linq to sql?

Tags:

linq

I saw some code were linq was used on a traversing a dictionary object in c#. I thought linq was just for linq to sql for databases. The linq used in the code mentioned was a select type statement, just no database.

Is there linq without linq to sql for databases? Is that "linq" without the "sql" here to stay? I ask that because people talk about the entity framework replacing linq to sql but certainly the EF is not replacing linq that is used the fashion I described is it? Can you use the ef on a dictionary object? Hoping for comments. Thanks.

Heres where I saw it:

How to find duplicate pairs in a Dictionary?

like image 336
johnny Avatar asked Dec 03 '22 10:12

johnny


2 Answers

Linq is a .NET framework based technology to query objects (anything that implements IEnumerable). Linq to SQL is an extension to that, that allows you to query SQL Server databases.

Yes, Linq, without the SQL, is here to stay. It is a fabulous technology. One of the best things, IMO, to come out of Redmond, in a long time.

like image 57
Randy Minder Avatar answered Jan 02 '23 21:01

Randy Minder


LINQ stands for "Language Integrated Query" and is more than just a way to query SQL databases:

http://msdn.microsoft.com/en-us/library/bb397926.aspx

From the link above:

LINQ introduces standard, easily-learned patterns for querying and updating data, and the technology can be extended to support potentially any kind of data store.

LINQ is used all over the .NET framework now, and, as you mentioned in your question, is available to use against the native generic collection types. For me, this has completely changed how I write code:

List<int> myIntList = new List<int>();
.... populate with some data
myFilteredIntList = myIntList.Where(i => i > 10);

In addition to LINQ to SQL, there is LINQ to Objects, LINQ to XML, and LINQ to ADO.net.

Microsoft has been heavily investing in the LINQ feature set and it is here to stay... that being said, LINQ-to-SQL looks like it will be eventually retired in favor of LINQ to ADO.Net (Also known as Linq to Entities): http://blogs.msdn.com/b/adonet/archive/2008/10/29/update-on-linq-to-sql-and-linq-to-entities-roadmap.aspx

like image 29
jslatts Avatar answered Jan 02 '23 20:01

jslatts