LINQ Principal Program Manager, Microsoft Corporation

Được đăng lên bởi nanaleu
Số trang: 68 trang   |   Lượt xem: 2302 lần   |   Lượt tải: 0 lần
Foreword by Luca Bolognese

LINQ Principal Program Manager, Microsoft Corporation




Paolo Pialorsi
Marco Russo

Chapter 6

Tools for LINQ to SQL
The best way to write queries using LINQ to SQL is by having a DataContext-derived class
in your code that exposes all the tables, stored procedures, and user-defined functions you
need as properties of a class instance. You also need entity classes that are mapped to the database objects. As you have seen in previous chapters, this mapping can be made by using
attributes to decorate classes or through an external XML mapping file. However, writing this
information by hand is tedious and error-prone work. You need some tools to help you
accomplish this work.
In this chapter, you will learn about what file types are involved and what tools are available to
automatically generate this information. The .NET 3.5 Software Development Kit (SDK)
includes a command-line tool named SQLMetal. Microsoft Visual Studio 2008 offers an integrated graphical tool named the Object Relational Designer. We will examine both tools from
a practical point of view.

In this chapter we use the version of the Northwind database that is included
in the C# samples provided with Visual Studio 2008. All the samples are contained in the
Microsoft Visual Studio 9.0\Samples\1033\CSharpSamples.zip file in your program files directory if you installed Visual Studio 2008. You can also download an updated version of these
samples from 

File Types
There are three types of files involved in LINQ to SQL entities and a mapping definition:

Database markup language (.DBML)


Source code (C# or Visual Basic)


External mapping file (XML)

A common mistake is the confusion between DBML and XML mapping files. At first sight,
these two files are similar, but they are very different in their use and generation process.

DBML—Database Markup Language
The DBML file contains a description of the LINQ to SQL entities in a database markup
language. Visual Studio 2008 installs a DbmlSchema.xsd file, which contains the schema definition of that language and can be used to validate a DBML file. The namespace used for this



Part II

LINQ to Relational Data

file is  which is different from the
namespace used by the XSD for the XML external mapping file.
Note You can find the DbmlSchema.xsd schema file in the %ProgramF...
Để xem tài liệu đầy đủ. Xin vui lòng
LINQ Principal Program Manager, Microsoft Corporation - Người đăng: nanaleu
5 Tài liệu rất hay! Được đăng lên bởi - 1 giờ trước Đúng là cái mình đang tìm. Rất hay và bổ ích. Cảm ơn bạn!
68 Vietnamese
LINQ Principal Program Manager, Microsoft Corporation 9 10 7