Nhib1_2.0 Configuration

Source: Internet
Author: User
. Required dynamic library support
Antl3.runtime. dll
Castle. Core. dll
Castle. DynamicProxy2.dll
Iesi. Collections. dll
Log4net. dll
Nhib.pdf. ByteCode. Castle. dll
Nhib.pdf. ByteCode. LinFu. dll
Nhib.pdf. dll
2. Create a database

If exists (SELECT * FROM dbo. sysobjects where id = object_id (N 'dbo. [CustomerOrders] ') and OBJECTPROPERTY (id, N 'isforeignkey') = 1)
Alter table dbo. [Order] drop constraint [CustomerOrders]
GO

If exists (SELECT * FROM dbo. sysobjects where id = object_id (N 'dbo. [OrderProducts] ') and OBJECTPROPERTY (id, n'isforeignkey') = 1)
Alter table dbo. [OrderProduct] drop constraint [OrderProducts]
GO

If exists (SELECT * FROM dbo. sysobjects where id = object_id (N 'dbo. [ProductOrders] ') and OBJECTPROPERTY (id, n'isforeignkey') = 1)
Alter table dbo. [OrderProduct] drop constraint [ProductOrders]
GO

If exists (SELECT * FROM dbo. sysobjects where id = object_id (N 'dbo. [Customer] ') and OBJECTPROPERTY (id, N 'isusertable') = 1)
Drop table dbo. [Customer]
GO

If exists (SELECT * FROM dbo. sysobjects where id = object_id (N 'dbo. [Order] ') and OBJECTPROPERTY (id, N 'isusertable') = 1)
Drop table dbo. [Order]
GO

If exists (SELECT * FROM dbo. sysobjects where id = object_id (N 'dbo. [OrderProduct] ') and OBJECTPROPERTY (id, N 'isusertable') = 1)
Drop table dbo. [OrderProduct]
GO

If exists (SELECT * FROM dbo. sysobjects where id = object_id (N 'dbo. [Product] ') and OBJECTPROPERTY (id, N 'isusertable') = 1)
Drop table dbo. [Product]
GO

Create table dbo. [Customer] (
[CustomerId] int IDENTITY (1, 1) not null,
[Firstname] varchar (50) NULL,
[Lastname] varchar (50) NULL
)
GO

Alter table dbo. [Customer] WITH NOCHECK ADD
CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED
(
[CustomerId]
) ON [PRIMARY]
GO

Create table dbo. [Order] (
[OrderId] int IDENTITY (1, 1) not null,
[OrderDate] datetime DEFAULT (getdate () not null,
[Customer] int NOT NULL
)
GO

Alter table dbo. [Order] WITH NOCHECK ADD
CONSTRAINT [PK_Order] PRIMARY KEY CLUSTERED
(
[OrderId]
) ON [PRIMARY]
GO

Create table dbo. [OrderProduct] (
[Product] int not null,
[Order] int NOT NULL
)
GO

Alter table dbo. [OrderProduct] WITH NOCHECK ADD
CONSTRAINT [PK_OrderProduct] PRIMARY KEY CLUSTERED
(
[Product],
[Order]
) ON [PRIMARY]
GO

Create table dbo. [Product] (
[ProductId] int IDENTITY (1, 1) not null,
[Name] varchar (50) not null,
[Cost] decimal (18,2) NOT NULL
)
GO

Alter table dbo. [Product] WITH NOCHECK ADD
CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED
(
[ProductId]
) ON [PRIMARY]
GO

Alter table dbo. [Order] ADD
CONSTRAINT [CustomerOrders] FOREIGN KEY
(
[Customer]
) REFERENCES dbo. [Customer] (
[CustomerId]
)
GO

Alter table dbo. [OrderProduct] ADD
CONSTRAINT [OrderProducts] FOREIGN KEY
(
[Order]
) REFERENCES dbo. [Order] (
[OrderId]
)
GO

Alter table dbo. [OrderProduct] ADD
CONSTRAINT [ProductOrders] FOREIGN KEY
(
[Product]
) REFERENCES dbo. [Product] (
[ProductId]
)
GO

3. Use ORMCodeGenerator2.0 to generate hbml files and source code files
4. Modify the file if any configuration is incorrect.
5. Simple example project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.