MereMortal
MereMortal

Reputation: 121

LINQ or ADO.net Entity Framework - which to learn?

A bit of a clarification: I was browsing Julia Lerman's Oreilly title on Entity framework and I got mighty confused.

I have Charlie Calvert's essential LINQ, but from my 10 minute session with Lerman's book, it transpires that LINQ is LINQ to SQL which seems underpowered with its DataContext object etc...

Whereas Entity Framework is the future, but it has something called Entity SQL which to my eye looked exactly like Transact-SQL. Now my eye could be a bit rusty, but the question is:

Since Entity Framework is the main horse that Microsoft is backing, is there any point in learning LINQ to SQL with its

        var numberGroups =
            from n in numbers
            group n by n % 5 into g
            select new { Remainder = g.Key, Numbers = g };

And am I confused in thinking that Entity SQL and LINQ are two different technologies, does entity SQL in fact use LINQ?

Upvotes: 12

Views: 3890

Answers (8)

Cédric Boivin
Cédric Boivin

Reputation: 11341

I go in microsoft TehcDays in Montreal on december 2 and 3, and they said, that they will no longer support LINQ to sql in few year, so your better start to learn LinQ to entity (Entity framework).

Upvotes: 0

Marc Gravell
Marc Gravell

Reputation: 1062685

LINQ != LINQ-to-SQL

LINQ is the concept, including some language support. There are many implementations - LINQ-to-SQL is one, as is ADO.NET Data Services, Entity Framework's LINQ-to-Entities, LINQ-to-Objects, LINQ-to-SQL, LINQ-to-Amazon, DbLinq, etc.

You still use LINQ with Entity Framework; indeed, LINQ-to-Entities is the preferred choice, giving compile time static checking. Entity SQL is simply another mechanism (in addition to LINQ-to-Entities) for querying the EDM (Entity Data Model).

There are 3 main reasons that ESQL is useful:

  • it was the only option in early previews when LINQ-to-Entities was still under construction
  • it can be used in some scenarios where there is no object model, for example reporting services
  • there is a small number of cases where ESQL is more expressive

For everything else, LINQ should be your tool for working with Entity Framework.

Upvotes: 25

Linus
Linus

Reputation: 1256

From what I understand, EF is not quite ready for prime time yet, and it does not support many of the LINQ constructs that work so easily today in LINQ2SQL.

If you can commit to SQL Server for your application, I say today, learn LINQ2SQL. You'll have more capabilities in querying when using LINQ.

I'm betting when EF is ready, it'll be a much easier transition for you since the query language should be transferrable.

Good luck.

Upvotes: 0

Min
Min

Reputation: 2975

Whoa whoa. Slow down there.

Short Answer: Entity Framework

Longer Answer:

LINQ to SQL and Entity Framework are data access technologies.

Linq is, according to MS,

LINQ is a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.

from : http://msdn.microsoft.com/en-us/netframework/aa904594.aspx

Both LINQ to SQL and Entity Framework have Linq providers, which allow for that awesome syntax when querying against them.

Upvotes: 1

Chris Brandsma
Chris Brandsma

Reputation: 11736

As others said, you probably mean Linq to SQL vs Entity Framework.

Both work for SQL Server, but only Entity Framework will work for other databases. Also, LINQ to SQL has, more or less, been depreciated. So go with Entity Framework.

Upvotes: 4

Sergejus
Sergejus

Reputation: 557

Entity Framework has LINQ to Entities, so you can execute very the same query against EF as well. And my answer will be invest more to EF, because upcomming EFv4 seems promissing.

Upvotes: 0

Ali Shafai
Ali Shafai

Reputation: 5161

Linq is a programming construct that allows you query your objects

there is a Linq to Sql that I think you are talking about.

you can always use linq to query EF objects...

Upvotes: 1

John Saunders
John Saunders

Reputation: 161773

LINQ is a generic term for the language features that permit queries to be written in C# or VB.NET over a data store of some sort. There is LINQ to SQL, LINQ to Entities, LINQ to Objects, etc.

LINQ to SQL closely models the physical database structure. It produces one type for every table in the database. If your database changes, then your LINQ to SQL code will need to change.

LINQ to Entities more closely models the conceptual database design. It allows you to map to the physical database, but for instance, allows you to create one Person entity that includes data from both the Person and Contacts tables. This allows your callers to think in terms of what the data mean instead of how the data are implemented.

Also, Microsoft has said that future development in LINQ to SQL will be limited when compared to the development in LINQ to Entities. Given the increased flexibility and the fact that LINQ to SQL won't get many more enhancements, I'd go with LINQ to Entities and Entity Framework.

Upvotes: 9

Related Questions