How To Create The Multi-level Class Library DataEntityTier

Step:1 Click the File menu and choose New Project.

 
In the New Project dialog box, select Windows in the Project Types pane.
 
Click the Class Library template and DataEntityTier Specify the name of the project.
 
Specify the name of the solution and NTierWalkthrough OK.
 
This creates a solution containing the draft NTierWalkthrough DataEntityTier that is added to Solution Explorer.
 
Step 2: To create a new class library for the TableAdapter:
 
Right-click on the Solution Explorer and choose to Add New Project so just add a new project to the solution NTierWalkthrough.
 
In the Templates pane of the New Project dialog box, click Class Library, and DataAccessTier Give the project name, then
 
Click OK.
 
DataAccessTier the project is created and added to the solution NTierWalkthrough.
 
Step 3: To create the dataset
 
Click DataAccessTier in Solution Explorer and choose Show Data Sources from the Data menu.
 
In the Data Sources window, click Add New Data Source to start the Configure Data Source wizard.
 
On the Select, a data source type, click Database, and click Next.
 
On the Choose Your Data Connection page does one of the following:
 
Select the data connection to the Northwind sample database, drop-down list, if present.
 
or Click New Connection to open the Add Connection dialog box and choose a database on SQL Server.
 
Click Next on the Save connection string in application configuration files Expand the Tables node in the page.
 
Choose your database objects. Select the checkboxes for the Customers and Orders tables, and then click Finish.
 
DataAccessTier NorthwindDataSet is added to the project and appears in the Data Sources window.
 
Step 4: To separate the TableAdapter in the dataset:
 
Double-click NorthwindDataSet.xsd in Solution Explorer to open the dataset in the Dataset Designer.
 
Click an empty area of the designer.
 
Locate the DataSet Project node in the Properties window.
 
DataSet Project list, click DataEntityTier.
 
Select Build Solution from the Build menu.
 
Step 5: To create a new WCF service application:
 
To add a new project, right-click Solution Explorer, choose Add New Project.
 
In the New Project dialog box, select WCF in the Project Types pane. In the Templates pane, click Library and WCF Service.
 
Name the project DataService name, then click OK.
 
DataService the project is created and added to the solution NTierWalkthrough.
 
Step 6: Create a method in the data access layer to return the Customers table and Orders table.
 
Double NorthwindDataSet.xsd on in Solution Explorer to open the dataset in the Dataset Designer.
 
Click the right mouse button and select Add Query on CustomersTableAdapter to open the Query Wizard
 
TableAdapter.
 
On the Select, a type of command to leave the default Use SQL Statements and click Next.
 
In the Choose a Query Type page, leave the default SELECT statement that returns rows, then click Next.
 
On the Specify a SQL SELECT query, leave the default and click Next.
 
On the Choose the type GetCustomers methods to generate the method name in the Return a DataTable.
 
Click Finish.
 
Please note that the same procedure must be repeated for the Orders table, ok?
 
And then from the Build menu, click Rebuild Solution and compiled.
 
Step 7: To add references to the data service:
 
In Solution Explorer, right-click the right mouse button and choose Add Reference on DataService.
 
In the Add Reference dialog box, click the Projects tab and select both projects and DataAccessTier DataEntityTier. 
 
And OK.
 
Step 8: Create functions and GetCustomers GetOrders in the data service:
 
DataService in the project, double-click IService1.cs. and add the following code below the comment.
 
Then double-click Service1.cs.e and add the following code to the Service1 class.
 
Then fill in the Solution.
 
Step 9: Create the presentation layer:
 
To add a new project, right-click Solution Explorer, choose Add New Project.
 
In the New Project dialog box, select Windows in the Project Types pane, and in the Templates pane, click Windows Application.
 

Forms

 
Give the project name PresentationTier, then click OK.
 
PresentationTier The project is created and added to the solution NTierWalkthrough.
 
To set the new project as a startup project, in Solution Explorer, right-click the right mouse button and click on PresentationTier.
 
Set as StartUp Project.
 
Now we PresentationTier please add a project reference, then click the right-click and PresentationTier. 
 
Choose Add Reference. In the Add Reference dialog box, click the Projects tab and then click Select DataEntityTier.
 
OK.
 
At this point, you di Nuovo click the right-click and choose Add Reference PresentationTier service.
 
In the Add Reference dialog box, click Find in the service and select Service1 and OK.
 
Step 10: Add two data-bound DataGridView to the form:
 
In Solution Explorer, select the project and PresentationTier In the Data Sources window, expand NorthwindDataSet, then find the node
 
Customers. Drag the Customers node onto Form1.
 
In the Data Sources window, expand the Customers node, and find the related Orders, nested in the Customers node.
 
Drag the node onto Form1 and related Orders Create a handler for the Form1_Load event by double-clicking an empty area of the form.
 
Add the following code to the Form1_Load event handler.
 
Now double-click the app. Config and Project PresentationTier apritelo.Trovare the dimension attribute and maxReceivedMessageSize
 
change the value to 6553600.
 
Now press F5 and you will notice that the Customers and Orders tables of data are retrieved from the data service and displayed on the form.
 
Have to fun everyone! By Anna.


Similar Articles