tailieunhanh - Hướng dẫn học Microsoft SQL Server 2008 part 85

LINQ cho các thực thể là nhiều hơn một công cụ đơn giản ORM. Các Entity Framework và LINQ to Các đối tượng cho phép các nhà phát triển để làm việc với một mô hình khái niệm mà cung cấp bản đồ linh hoạt hơn, cung cấp khả năng sử dụng một mức độ rộng lớn hơn của phương sai từ các nguồn dữ liệu cơ bản. | PartV Data Connectivity LINQ to Entities is more than a simple ORM tool. The Entity Framework and LINQ to Entities enable developers to work against a conceptual model that offers more flexible mapping which provides the capability to utilize a wider degree of variance from the underlying data source. What determines whether a project should use LINQ to SQL or LINQ to Entities Entity Framework You should use LINQ to SQL when you want the following A rapid development cycle An ORM solution and a 1 1 data object model mapping Optimized performance through stored procedures and compiled queries To generate your own CLR classes versus using generated classes or deriving from base classes In contrast LINQ to Entities and the Entity Framework should be used when the following apply Your application targets different database engines in addition to Microsoft SQL Server Your physical database structure could be significantly different from your object model. That means you still want the benefits of an ORM but your classes may or may not map 1 1 with your database schema. You want to optimize performance through stored procedures and compiled queries The LINQ query should work in a database vendor-neutral manner You want to define application domain models to be used as the basis for a persistence layer This section introduces LINQ to Entities and the Entity Framework and illustrates by example how easy it is to create entities and query them using LINQ. Everything needed to use LINQ to Entities and the Entity Framework is installed with Visual Studio 2008 SP1 which can be downloaded from the following location downloads FamilyId FBEE1648-7106-44A7-9649-6D9F6D58056E displaylang en Creating and querying entities using LINQ After installing the service pack create a new Visual Studio C Windows forms project. When the project is loaded add a new item to it. In the Add New Item dialog you will notice a new item in the list of templates .