Udostępnij za pośrednictwem


Data Sample

The Data sample is designed to support many scenarios that are demonstrated in the various LINQ samples. If you install this sample under the same parent folder as the other LINQ samples, all the paths in those other samples will be resolved correctly.

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  • Press F5.

Demonstrates

This data directory is used by several other LINQ samples. Note the copy of the database titled Northwind.mdf in this directory. This is a custom version of the Northwind database that is used by many Microsoft products. Changes made to this database include the addition of new stored procedures and fields designed to demonstrate particular LINQ features. There is a second copy of this database in the SampleQueries project. Two copies of Northwind were shipped so that SampleQueries can be copied easily as a discrete entity from one location to another. If you move other samples, such as LinqToNorthwind, you would also have to bring this data directory, too.

Other files in this directory include various small XML files that are used by some other LINQ samples. Note that these XML files are again duplicated in the SampleQueries directory, for the same reason outlined earlier.

It is important that the files in this directory are not marked as read-only. Many of the samples will not run correctly if these files have their read-only attribute set. In particular, you may have trouble connecting to the Northwind database unless you have permissions to both read and write to Northwind.mdf.

The following text, which summarizes some of the information explained in this file, is duplicated in most of the other ReadMe.html files included with the LINQ samples.

Note

Many LINQ samples require XML files and/or the version of the Northwind sample database that is located in the Data sample. If you install the Data Sample in the same parent folder as the other LINQ samples, the path for the XML files and database file will be resolved automatically. Many sample files also require the Object Dumper Sample project.

See Also

Concepts

LINQ Query Expressions (C# Programming Guide)

Other Resources

LINQ to SQL

LINQ Samples