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 Dataset Designer 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ção:

Seu computador pode mostrar diferentes nomes ou localizações para alguns dos elementos de 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 do Visual Studio.

To separate the dataset into a different project

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

    Observaçã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ção:

    Quando Você separado conjuntos de dados e TableAdapters (definindo a DataSet Projectpropriedade ), classes parcial do dataset existente no projeto não serão movidas automaticamente.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ção:

Com o conjunto de dados ou TableAdapter projeto selecionado, clicar Mostrar todos os arquivos in O gerenciador de soluções para exibir o arquivo de classe gerada.

Consulte também

Tarefas

Demonstra Passo a passo: Criando um aplicativo de dados N-tier

Conceitos

Visão geral de aplicativo de dados de N camadas

O que Há de Novo em Dados

Outros recursos

Atualização hierárquica

Acessando Dados (Visual Studio)

ADO.NET