views:

1527

answers:

9

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?

post the many replies I got:

Ok Folks, I'm new to this, so I'm editing my answer this time ;-) Many thanks for your full, expedited and very helpful answers. Regards MereMortal

+8  A: 

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.

John Saunders
+1  A: 

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...

Ali Shafai
+19  A: 

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.

Marc Gravell
well said :) Learn linq.
Pure.Krome
Marc,eSQL is good for dynamic queries too. Sure you can do the same things with expression manipulations etc, but most people are a lot more comfortable manipulating strings than expression trees.
Alex James
Entity SQL can be used with those programming languages which does not have support for LINQ like Managed C++.
Nilesh Gule
A: 

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.

Sergejus
A: 

so what is Entity SQL then pls?

MereMortal
I've added some bullets in my answer to cover this
Marc Gravell
You should edit your original question instead of creating an answer.
John Saunders
This is a question, not an answer.
Homer
+2  A: 

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.

Chris Brandsma
A: 

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.

Min
A: 

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.

Linus
EF4 (which will ship in .NET 4.0 / VS2010) seems to correct a lot of the flaws and shortcoming of the current EF and looks very promising! http://blogs.msdn.com/adonet/archive/tags/Entity+Framework/default.aspx
marc_s
many thanks for that really helpful answer Linus, I had started to reach the same conclusion myself. I reasoned that EF is pretty elaborate and tearing myself away from ADO.Net command/connection/ etc..to learn LINQ to SQL is probably a good and useful first step, plus there are plenty of good references to LINQ to SQL, whilst EF is not that extensively written about.
MereMortal
A: 

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).

Cédric Boivin
LINQ to SQL was a short term solution. As the name suggests it works specifically with SQL server only. EF on the other hand has support for multiple databases. You can refer to one of the blogpost I wrote earlier comparing the two technologies http://nileshgule.blogspot.com/2010/09/entity-framework-part-2-comparison.html
Nilesh Gule