Version
1.2 [2006-11-12]
Brief introduction
This tutorial, on the basis of the previous article "NBearV3 Step through step tutorial--orm", demonstrates the entity autocorrelation relationships that are not covered in the previous article; Settings for performance-related attributes: Indexproperty,batchupdate , and discusses the use and considerations of strongly typed query methods in the NBear.Data.Gateway class, especially the performance variance analysis under different attribute setting options.
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 more fully grasp the use of NBearV3 ORM module for application design process, understand the physical design of the important performance-related options, and fully understand the NBear.Data.Gateway in the use of various strong-type query methods.
Code
This tutorial shows all the projects and code you created, contained in the Tutorials\orm_adv_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
<30 minutes.
Body
Step 1 Download the latest version of NBEARV3 and prepare
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, tutorials directory. In this tutorial, you will use the ORM Basics tutorials in all release compiled versions of DLLs and EXE and tutorials directories in the Dist directory.
1.3 Copy the entire orm_tutorial directory in the tutorials directory to any other location and name it orm_adv_tutorial, we will demonstrate the ORM advanced knowledge in NBearV3 based on Orm_tutorial.
Step 2 extended design entities and metadata
2.1 Rename the Orm_tutorial.sln in orm_adv_tutorial to Orm_adv_tutorial.sln and open in the VS2005 development environment.
2.2 In the Group.cs file of the Entitydesigns project, add the ParentID property and add the Indexpropertyattribute setting for the ParentID property as follows:
[IndexProperty]
Guid ParentID
{
get;
set;
}
Marking a property as indexproperty means that a single-column index is automatically created for the property in the database creation script that is generated by NBear.Tools.EntityDesignToEntity.exe. We all understand the role of database indexing-which will help to improve query performance with this attribute as a condition.