Compartilhar via


Como: separar Datasets e TableAdapters em diferentes projetos

Typed datasets have been enhanced so that the TableAdapters and dataset classes can be generated into separate projects.This enables you to quickly separate application layers and generate n-tier data applications.

The following procedure describes the process of using the Criando e editando conjuntos de dados tipados to generate dataset code into a project that is separate from the project that contains the generated TableAdapter code.

Separating Datasets and TableAdapters

When you separate dataset code from TableAdapter code, the project that will contain the dataset code must be located in the current solution.If this project is not located in the current solution, it will not be available in the DataSet Project list in the Properties window.

ObservaçãoObservação

Seu computador pode mostrar nomes ou locais diferentes para alguns dos elementos da interface do usuário do Visual Studio nas instruções a seguir. A edição do Visual Studio que você possui e as configurações que você usa determinam esses elementos. Para obter mais informações, consulte Configurações de Visual Studio.

To separate the dataset into a different project

  1. Open a solution that contains a dataset (.xsd file).

    ObservaçãoObservação

    If the solution does not contain the project into which you want to separate your dataset code, create it, or add an existing project to the solution.

  2. Double-click a typed dataset file (an .xsd file) in Solution Explorer to open the dataset in the Dataset Designer.

  3. Click an empty area of the Dataset Designer.

  4. Locate the DataSet Project node in the Properties window.

  5. In the DataSet Project list, click the name of the project into which you want to generate the dataset code.

    After you click the project into which you want to generate the dataset code, the DataSet File property is populated with a default file name.You can change this name if you have to.Additionally, if you want to generate the dataset code into a specific directory, you can set the Project Folder property to the name of a folder.

    ObservaçãoObservação

    When you separate datasets and TableAdapters (by setting the DataSet Project property), existing partial dataset classes in the project will not be moved automatically.Existing dataset partial classes must be manually moved to the dataset project.

  6. Salve o dataset

    The dataset code is generated into the project selected in the DataSet Project property, and the TableAdapter code is generated into the current project.

By default, after you separate the dataset and TableAdapter code, the result is a discrete class file in each project.The original project has a file that is named DatasetName.Designer.vb (or DatasetName.Designer.cs) that contains the TableAdapter code.The project designated in the Dataset Project property has a file that is named DatasetName.DataSet.Designer.vb (or DatasetName.DataSet.Designer.cs) that contains the dataset code.

ObservaçãoObservação

With the dataset or TableAdapter project selected, click Show All Files in Solution Explorer to view the generated class file.

Consulte também

Tarefas

Passo a passo: Criando um aplicativo de dados de n camadas

Conceitos

Visão geral dos aplicativos de dados de n camadas

Novidades para desenvolvimento de aplicativos de dados no Visual Studio 2012

Outros recursos

Atualização hierárquica

Acesso a dados em Visual Studio

ADO.NET