none
Difference between LINQ to SQL and LINQ to Entity

    Question

  • Hi all i want to know what is the difference between LINQ to SQL and LINQ to Entity??I am little bit confused.
    Monday, February 28, 2011 4:53 PM

Answers

  • Hi chandu123;

    From the Julie Lerman's Blog author of a couple of books on the subject, LINQ to SQL vs. Entity Framework She give good differences between the two.

    Blog message re-posted here:
    Besides that Linq to SQL is only for SQL () one of the big differences is that the EDM is more flexible and more loosely coupled because of the 3-tiered model (conceptual layer, source schema and the mapping layer in between).  For example, you could have one conceptual layer and then multiple mapping layers that point to mulitple databases. In LINQ to SQL, your dbml properties are tightly bound directly to one particular field in a table.

    While these are not in the March 2007 CTP, EDM is getting the ability to build views of the conceptual layer as well as to write stored procedures in the mapping layer. These are really cool features. I don't believe you can do this with Linq to SQL, but a) I could be mistaken and b) that may be something that is forthcoming.

    In addition to Linq to Entities, Entity SQL can be used to query entities. This can be either through the object services API or the Entity CLient (the one which gives you connections/commands and results in a dbDataReader). Entity SQL, while not as elegant as using the strongly typed LINQ, has the advantage of enabling dynamic queries, since you use a string to build a query, much like TSQL.

    Both Linq to SQL and EDM allow inheritance and extending the code generated class with addtional partial classes. EF allows many to many relationships. I believe that LINQ to SQL will NOT be getting this by RTM.

     

    Fernando


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Monday, February 28, 2011 7:04 PM
  • On 3/1/2011 10:24 AM, chandu123 wrote:
    > But the disadvantage of linq is it cannot interact with Oracle DB so how
    > it can be achieved??
     
    What are you talking about? There are Linq providers for Oracle.
     
     
    What is Linq?
     
    Language Integrated Query (LINQ, pronounced "link") is a Microsoft .NET
    Framework component that adds native data querying capabilities to .NET
    languages.
     
    LINQ defines a set of method names (called standard query operators, or
    standard sequence operators), along with translation rules from
    so-called query expressions to expressions using these method names,
    lambda expressions and anonymous types. These can, for example, be used
    to project and filter data in arrays, enumerable classes, XML (LINQ to
    XML), relational database, and third party data sources. Other uses,
    which utilize query expressions as a general framework for readably
    composing arbitrary computations, include the construction of event
    handlers[1] or monadic parsers.[2]
     
     
     
     
    You can connect EF 4.0 to an IBM mainframe ISeries DB2 database and run
    Linq queries against the database.
     
     
    Wednesday, March 02, 2011 5:37 AM

All replies

  • Hi chandu123;

    From the Julie Lerman's Blog author of a couple of books on the subject, LINQ to SQL vs. Entity Framework She give good differences between the two.

    Blog message re-posted here:
    Besides that Linq to SQL is only for SQL () one of the big differences is that the EDM is more flexible and more loosely coupled because of the 3-tiered model (conceptual layer, source schema and the mapping layer in between).  For example, you could have one conceptual layer and then multiple mapping layers that point to mulitple databases. In LINQ to SQL, your dbml properties are tightly bound directly to one particular field in a table.

    While these are not in the March 2007 CTP, EDM is getting the ability to build views of the conceptual layer as well as to write stored procedures in the mapping layer. These are really cool features. I don't believe you can do this with Linq to SQL, but a) I could be mistaken and b) that may be something that is forthcoming.

    In addition to Linq to Entities, Entity SQL can be used to query entities. This can be either through the object services API or the Entity CLient (the one which gives you connections/commands and results in a dbDataReader). Entity SQL, while not as elegant as using the strongly typed LINQ, has the advantage of enabling dynamic queries, since you use a string to build a query, much like TSQL.

    Both Linq to SQL and EDM allow inheritance and extending the code generated class with addtional partial classes. EF allows many to many relationships. I believe that LINQ to SQL will NOT be getting this by RTM.

     

    Fernando


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Monday, February 28, 2011 7:04 PM
  • On 2/28/2011 11:53 AM, chandu123 wrote:
    > Hi all i want to know what is the difference between LINQ to SQL and
    > LINQ to Entity??I am little bit confused.
     
    The ADO.Entity Framework allows you to access various database providers
    like MySQL, SQL Server, Oracle, Sybase, DB2 etc, etc. Link-2-SQL only
    allows you to access SQL Server.
     
    So, you may have a solution that requires access to SQL Server and
    Oracle. You can do it with EF.
     
    Tuesday, March 01, 2011 2:05 AM
  • But the disadvantage of linq is it cannot interact with Oracle DB so how it can be achieved??
    Tuesday, March 01, 2011 3:24 PM
  • Hi Chandu123,

       Please review:

        Entity Framework vs. LINQ


    Thanks,

    Paras Sanghani

    http://parassanghani.blogspot.com/

    Mark As Answer if it helped you.

    Tuesday, March 01, 2011 6:23 PM
  • On 3/1/2011 10:24 AM, chandu123 wrote:
    > But the disadvantage of linq is it cannot interact with Oracle DB so how
    > it can be achieved??
     
    What are you talking about? There are Linq providers for Oracle.
     
     
    What is Linq?
     
    Language Integrated Query (LINQ, pronounced "link") is a Microsoft .NET
    Framework component that adds native data querying capabilities to .NET
    languages.
     
    LINQ defines a set of method names (called standard query operators, or
    standard sequence operators), along with translation rules from
    so-called query expressions to expressions using these method names,
    lambda expressions and anonymous types. These can, for example, be used
    to project and filter data in arrays, enumerable classes, XML (LINQ to
    XML), relational database, and third party data sources. Other uses,
    which utilize query expressions as a general framework for readably
    composing arbitrary computations, include the construction of event
    handlers[1] or monadic parsers.[2]
     
     
     
     
    You can connect EF 4.0 to an IBM mainframe ISeries DB2 database and run
    Linq queries against the database.
     
     
    Wednesday, March 02, 2011 5:37 AM