views:

152

answers:

4

What is the difference between LINQ and Entity Framework

Are both LINQ and Entity Framework both considered ORM?

What is the advantages of both.

A: 

linq stand for " Language-Integrated Query ", so you can use it to translate your tsql query in c# code.

Entity Framework is properly a framework to let you model your domain top-down

frabiacca
+3  A: 

LINQ is a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations.

Entity Framework is an object-relational mapping (ORM) framework for the .NET Framework.

QuBaR
Entity Framework is a modeling framework with ORM features built-in, but could be used against non-relational stores.
Max Toro
+3  A: 

LINQ allows you to query many different data sets using the same syntax. For example, with LINQ you can query a collection of strings or your own collection of objects or an array or XML for example all using the same syntax that looks similar to SQL syntax.

Entity Framework is an ORM, as well as LINQ to SQL. Both use LINQ to abstract the actual SQL being called to query records from the DB.

What's great about LINQ is it abstracts away the details needed to query each different data set. Before LINQ we were forced to know how to query each and every kind of data set which in many cases was very different.

Different data sets can participate with LINQ by creating a provider for it. For example, you can now use LINQ to access twitter with the LINQ to Twitter Provider.

klabranche
+1 for cool link :-)
IrishChieftain
+5  A: 

LINQ is a base technology - as others have already pointed out.

You're probably talking about Linq-to-SQL - which is a fairly simple, straightforward ORM for use with SQL Server.

Entity Framework also is an ORM - and then some! It's quite a different beast, really.

Linq-to-SQL is great

  • if you need very simple 1:1 mapping - one table equals one class in your domain model
  • if you never need anything else but SQL Server (Linq-to-SQL doesn't support anything else)
  • if you want to be up and running really quickly

Entity Framework on the other hand

  • supports multiple backends (SQL Server, Oracle, Firebird - other will likely follow)
  • supports a full conceptual data modelling strategy - you define the physical model in the database, the conceptual model in your app, and the mapping between the two
  • gives you the ability to handle things like mapping a single business entity to several tables
  • support table-per-hierarchy and table-per-class inheritance scenarios

In brief: Linq-to-SQL is a great, simple and lean'n'mean ORM for SQL Server - use it, if it does all you need. Entity Framework is quite a different beast, much more capable, but also much more complex, much bigger - perfect for your next enterprise-critical app, but probably overkill for your personal blog app :-)

marc_s