我尝试从https://github.com/jagregory/fluent-nhibernate/wiki/Getting-started运行示例,但在运行下一个代码后,所有表都被清除。我不明白为什么会这样。我希望该商店的商店var barginBasin = new Store { Name = "Bargin Basin" };
和表StoreProduct
中Store_id
的行将被删除。
using (var session = sessionFactory.OpenSession())
{
session.Delete(session.CreateCriteria(typeof (Store)).List<Store>()[0]);
session.Flush();
}
sessionFactory
初始化:
var dbConfig = OracleDataClientConfiguration.Oracle10
.ConnectionString(c => c.FromConnectionStringWithKey("Oracle"))
.Driver<OracleDataClientDriver>()
.ShowSql();
sessionFactory = Fluently.Configure()
.Database(dbConfig)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Employee>())
.BuildSessionFactory();
应用程序配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="Oracle"
connectionString="DATA SOURCE=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=[IP])(PORT=[PORT]))(CONNECT_DATA=(SERVICE_NAME=XE)));PASSWORD=[PASSWORD];PERSIST SECURITY INFO=True;USER ID=[USER ID]"
providerName="Oracle.DataAccess.Client" />
</connectionStrings>
</configuration>