菜鳥問NHibernate問題﹐尋求高手解決。
在測試類中做了下面的動作﹕
ISession s = SessionFactory.OpenSession();
ITransaction t = s.BeginTransaction();
try
{
s.Save(entity);
t.Commit();
}
catch(Exception e)
{
t.Rollback();
throw e;
}
finally
{
s.Close();
}
用NUnit測試﹐顯示sql語句怎么是這樣的呢﹐先刪除我的表﹐再建表﹐再新增。怎么是這樣的呢。暈
drop table G_users
drop table G_guestbook
create table G_users (
id INT IDENTITY NOT NULL,
name NVARCHAR(20) null,
email NVARCHAR(40) null,
password NVARCHAR(20) null,
flag INT null,
regtime DATETIME null,
primary key (id)
)
create table G_guestbook (
id INT IDENTITY NOT NULL,
userid INT null,
username NVARCHAR(20) null,
title NVARCHAR(100) null,
article NVARCHAR(255) null,
pubtime DATETIME null,
primary key (id)
)
NHibernate :INSERT INTO G_users (email, name, regtime, password, flag) VALUES (@p0, @p1, @p2, @p3, @p4); select SCOPE_IDENTITY()
在測試類中做了下面的動作﹕
ISession s = SessionFactory.OpenSession();
ITransaction t = s.BeginTransaction();
try
{
s.Save(entity);
t.Commit();
}
catch(Exception e)
{
t.Rollback();
throw e;
}
finally
{
s.Close();
}
用NUnit測試﹐顯示sql語句怎么是這樣的呢﹐先刪除我的表﹐再建表﹐再新增。怎么是這樣的呢。暈
drop table G_users
drop table G_guestbook
create table G_users (
id INT IDENTITY NOT NULL,
name NVARCHAR(20) null,
email NVARCHAR(40) null,
password NVARCHAR(20) null,
flag INT null,
regtime DATETIME null,
primary key (id)
)
create table G_guestbook (
id INT IDENTITY NOT NULL,
userid INT null,
username NVARCHAR(20) null,
title NVARCHAR(100) null,
article NVARCHAR(255) null,
pubtime DATETIME null,
primary key (id)
)
NHibernate :INSERT INTO G_users (email, name, regtime, password, flag) VALUES (@p0, @p1, @p2, @p3, @p4); select SCOPE_IDENTITY()