我正在尝试使用 fluentmapping 连接到 oracle 中的现有数据库。我得到了客户的映射
public CustomerMapping()
{
Not.LazyLoad();
Id(x => x.Cst_Recid).GeneratedBy.Increment() ;
}
我正在尝试创建会话
public static ISessionFactory CreateSessionFactory()
{
return Fluently
.Configure()
.Database(OracleClientConfiguration.Oracle10.ConnectionString
("...."))
.Mappings(m =>
{
m.FluentMappings.AddFromAssemblyOf<CustomerMapping>();
})
.BuildConfiguration()
.BuildSessionFactory();
}
我有一些试用课程可以尝试创建 sessionFactory
public class MyDataProvider
{
public static Customer GetCustomerById(long customerId)
{
ISessionFactory sessionFactory = SessionFactory.CreateSessionFactory();
ISession session = sessionFactory.OpenSession();
return session.Linq<Customer>().Where(x => x.Cst_Recid.Equals(temp)).FirstOrDefault();
}
}
即使我要打开会话并激活,我也无法通过 ID 获取客户...
测试非常简单——只检查选择活动
[Test]
public void CanGetCustomerById()
{
MyDataProvider provider = new MyDataProvider();
Assert.AreEqual(33941, MyDataProvider.GetCustomerById(33941).Cst_Recid);
}
有一个错误 -
TestCase '...DataLayer.Tests.CustomerMappingTests.CanGetCustomerById' 失败:NHibernate.ADOException:无法执行查询 [ select * from ( SELECT this_.Cst_Recid as Cst1_0_0_, this_.Cst_Customerid as Cst2_0_0_, this_.Cst_First_Name as Cst3_0_0_, this_.Cst_Group_Recid如Cst4_0_0_,this_.Cst_Insdbdt如Cst5_0_0_,this_.Cst_Insdbuser如Cst6_0_0_,this_.Cst_Joingroup_Dt如Cst7_0_0_,this_.Cst_Last_Name如Cst8_0_0_,this_.Cst_Lastupddt如Cst9_0_0_,this_.Cst_Lastupduser如Cst10_0_0_,this_.Cst_Tat_Lakoach_Meshalem如Cst11_0_0_,this_.Cst_Typeid如Cst12_0_0_ , this_.Cst_Tziyun_Meshalem_Rashi_Only as Cst13_0_0_, this_.Cst_Tziyun_Mizdamen as Cst14_0_0_ FROM "Customer" this_ WHERE this_.Cst_Recid = :p0 ) where rownum <=:p1 ] 位置参数:#0>33941 [SQL: select * from (SELECT this_.Cst_Recid作为 Cst1_0_0_,this_.Cst_Customerid如Cst2_0_0_,this_.Cst_First_Name如Cst3_0_0_,this_.Cst_Group_Recid如Cst4_0_0_,this_.Cst_Insdbdt如Cst5_0_0_,this_.Cst_Insdbuser如Cst6_0_0_,this_.Cst_Joingroup_Dt如Cst7_0_0_,this_.Cst_Last_Name如Cst8_0_0_,this_.Cst_Lastupddt如Cst9_0_0_,THIS_。 Cst_Lastupduser如Cst10_0_0_,this_.Cst_Tat_Lakoach_Meshalem如Cst11_0_0_,this_.Cst_Typeid如Cst12_0_0_,this_.Cst_Tziyun_Meshalem_Rashi_Only如Cst13_0_0_,this_.Cst_Tziyun_Mizdamen如Cst14_0_0_ FROM “客户” THIS_ WHERE this_.Cst_Recid =:P0)其中ROWNUM <=:P1] --- -> System.Data.OracleClient.OracleException:ORA-00942:表或视图不存在Cst_Joingroup_Dt为Cst7_0_0_,this_.Cst_Last_Name为Cst8_0_0_,this_.Cst_Lastupddt为Cst9_0_0_,this_.Cst_Lastupduser为Cst10_0_0_,this_.Cst_Tat_Lakoach_Meshalem为Cst11_0_0_,this_.Cst_Typeid为Cst12_0_0_,this_.Cst_Tziyun_Meshalem_Rashi_Only为Cst13_0_0_,this_.Cst_Tziyun_Mizdamen为Cst14_0_0_ FROM “客户” THIS_ WHERE this_.Cst_Recid = :p0 ) where rownum <=:p1] ----> System.Data.OracleClient.OracleException : ORA-00942: 表或视图不存在Cst_Joingroup_Dt为Cst7_0_0_,this_.Cst_Last_Name为Cst8_0_0_,this_.Cst_Lastupddt为Cst9_0_0_,this_.Cst_Lastupduser为Cst10_0_0_,this_.Cst_Tat_Lakoach_Meshalem为Cst11_0_0_,this_.Cst_Typeid为Cst12_0_0_,this_.Cst_Tziyun_Meshalem_Rashi_Only为Cst13_0_0_,this_.Cst_Tziyun_Mizdamen为Cst14_0_0_ FROM “客户” THIS_ WHERE this_.Cst_Recid = :p0 ) where rownum <=:p1] ----> System.Data.OracleClient.OracleException : ORA-00942: 表或视图不存在p1] ----> System.Data.OracleClient.OracleException : ORA-00942: 表或视图不存在p1] ----> System.Data.OracleClient.OracleException : ORA-00942: 表或视图不存在
他试图运行的查询是由 FluentNHibernate 自动构建的。如果我删除查询正确执行的引号,它会得到结果..问题是我无法根据需要更改查询..问题可能是我们使用的是 Oracle 11 g 而 FluentNhibernate 仅调整为 Oracle 9 或10 ?
将感谢任何帮助。