日期:2014-05-20 浏览次数:20885 次
namespace Thiess.Data
{
public class Product
{
public string m_ID { get; set; }
public string m_Name { get; set; }
}
}
static void Main(string[] args)
{
Product[] cs = new Product[MaxRow];
for (int i = 1; i <= MaxRow; i++)
{
StringBuilder sb = new StringBuilder();
sb.Append("用户");
sb.Append(i);
Product c = new Product();
c.m_ID = i.ToString();
c.m_Name = sb.ToString();
cs[i - 1] = c;
}
Console.WriteLine("=================== TEST START ===================");
Configuration cfg = new Configuration();
ISession session = cfg.BuildSessionFactory().OpenSession();
ITransaction transaction = session.BeginTransaction();
session.Save(cs[0]);
transaction.Commit();
session.Close();
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Thiess"
namespace="Thiess.Data">
<!-- more mapping info here -->
<class name="Product" table="Test_product_table" lazy="false">
<id name="m_ID" column="Product_ID" type="string">
<generator class="native" />
</id>
<property name="m_Name" column="Product_Name" type="string" length="20"/>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSqlCeDialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</property>
<property name="connection.connection_string">Data Source=FirstSample.sdf</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>