Version
1.2 [2006-11-12]
Brief introduction
This tutorial demonstrates the basic process of developing a Web application based on the NBearV3 IOC module. This tutorial also demonstrates the process of building a design entity from an existing database using the NBear.Tools.DbToEntityDesign.exe tool.
Note: Before reading this article, readers are advised to read the NBearV3 step by step tutorial--orm to master the basics of ORM in NBearV3.
Goal
Through this tutorial, readers should be able to master the basic process of using NBearV3 's IOC module and the process of using the NBear.Tools.DbToEntityDesign.exe tool to persist data persistence using NBEARV3 ORM components for projects that already have a database structure.
Code
This tutorial shows all the projects and code you created, contained in the Tutorials\ioc_tutorial directory in the NBearV3 latest source code ZIP package that you can download from sf.net. Therefore, if you have any questions in the course of using this tutorial, you can refer to the code directly.
Time
<45 minutes.
Body
Step 1 Download NBearV3 latest version
1.1 Access to Http://sf.net/projects/nbear, download the latest version of NBearV3 to the local directory.
1.2 Extract the downloaded zip file to C:\, you will see that the NBearV3 directory after the compression includes: Dist, doc, cases, SRC and other directories. In this tutorial, you will use the Dist directory, which contains all the DLLs and EXE versions that were compiled.
Step 2 Creating an application solution
2.1 Open the VS2005 development environment, create a new empty solution for SLN.
2.2 Add two new C # class library projects to the SLN, and two class library projects are named Entitydesigns and entities, removing Class1.cs files created automatically by the IDE.
2.3 Add two new C # class library projects to the SLN, and two class library projects are named Serviceinterfaces and Serviceimpls, removing Class1.cs files created automatically by the IDE.
2.4 Create a new asp.net Web application named website in SLn, adding a Web.config file for website.
Step 3 design entities, relationships, and meta data
3.1 Run dist\ NBear.Tools.DbToEntityDesign.exe, enter the following connection substring in the connection string text box:
server= (local);D atabase=northwind; Uid=sa; Pwd=sa
We will generate design entities for some of the tables and views we need from the demo database Northwind that SQL Server 2000 brings.
Click the Connect button to connect to the database and select the following tables or views from the tables on the left and view list (because this is mostly demo, we only select a few tables and views related to category and product): Categories, Products by Category. Click the Generate Entities Design button to right-click anywhere in the code-generated text box and select Copy to ClipBoard, which will copy all the code to the Clipboard.