Comparison between LINQ to SQL and LINQ to Entities

Source: Internet
Author: User
Recently, an article published by Elisa Flasko on MSDN compares the applicable scenarios of LINQ to SQL and LINQ to Entities:
Introducing LINQ to Relational Data
Http://msdn2.microsoft.com/en-us/library/cc161164.aspx

The author points out that the main application scenarios of LINQ to SQL are the rapid development of Microsoft SQL Server databases. The object models of these applications are very similar to the data-defined structures in databases, there is almost a one-to-one ing relationship, so that you can map some data tables directly. NET class, data fields mapped to the corresponding.. NET class. The author summarized as follows:

Use Cases of LINQ to SQL

  • I want to use the ORM scheme, and the database data definition corresponds to the object model.
  • I want to use the ORM scheme, and the Object Inheritance structure is stored in a single data table (single table inheritance)
  • To use the original CLR class, instead of using the generated class or inheriting from a base class, or to implement an Interface
  • Want to write a query using LINQ
  • If you want to use ORM, but the performance is very good, you can optimize the performance through the stored procedure and compiled query.

Note that, contrary to some outside legends, LINQ to SQL supports Object Inheritance. Although only one of the three common inheritance modes is supported, it also supports using external ing files.

The main application scenarios of LINQ to Entities are for scenarios requiring flexible and more complex ing, especially for enterprise applications, and access to other database systems. In these scenarios, the data table structure and object model may be very different, and application developers often do not have the right to generate or modify database data definitions.

Applicable scenarios of LINQ to Entities

  • Want to develop applications for Microsoft SQL Server or other Database Systems
  • You want to define the domain model and use it as the basis of the persistent layer.
  • To use the orm scheme, the object may have a correspondence with the database data definition, and the structure may be different.
  • You want to use an ORM solution that supports single-Table inheritance and other storage solutions (one table for each type and one table for each specific type ).
  • If you want to write a query using LINQ, and the query can work in different database systems
  • If you want to use ORM, but the performance is very good, you can optimize the performance through the stored procedure and compiled query.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.