基于oracle中遗留数据库的Fluent Nhibernate

基于oracle中遗留数据库的Fluent Nhibernate,oracle,nhibernate,fluent-nhibernate,ora-00942,Oracle,Nhibernate,Fluent Nhibernate,Ora 00942,我正在尝试使用fluentmapping连接到oracle中的现有数据库。 我得到了 映射到客户 public CustomerMapping() { Not.LazyLoad(); Id(x => x.Cst_Recid).GeneratedBy.Increment() ; } 我正在尝试创建会话 public static ISessionFactory CreateSessionFactory() { re

我正在尝试使用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();
    }
有一个错误-

TestCase'…DataLayer.Tests.CustomerMappingTests.CanGetCustomerById' 失败:NHibernate.ADOException:无法执行查询 [选择*从中选择这个项目。Cst被认为是Cst 1 0 0 0 0 0 0 0,这个项目。Cst客户被认为是Cst2 0 0 0 0 0 0 0 0 0 0,这个项目。这个项目。Cst第一个名字作为Cst3 0 0 0 0 0 0 0 0 0,这个项目。Cst第一个名字作为Cst3 0 0 0 0 0 0 0 0的名字作为Cst的名字,这个项目。Cst.Cst.Cst作为Cst作为Cst2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,这个项目,这个项目,这个项目,这个项目。Cst.Cst.Cst的用户作为Cst用户作为Cst用户作为CS6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,此.Cst\u lastupdddt为Cst9\u 0,此.Cst\u Lastupdu作为Cst10,这个Cst作为Cst11,这个Cst类型为Cst12,这个Cst类型为Cst12,这个Cst类型为Cst12,这个Cst类型为Cst12,这个Cst类型为Cst13,这个Cst类型为Cst13,这个Cst类型为Cst12,这个Cst类型为Cst12,这个Cst类型为Cst13,这里是Cst13,这个Cst类型为Cst14,这里是Cst=33941 [SQL:选择*从选择该项目作为Cst1 0 0 0 0 0 0 0 0,该项目作为Cst2 0 0 0 0 0 0 0 0 0,该项目作为Cst2 0 0 0 0 0 0 0 0 0 0,该项目作为Cst2 0 0 0 0 0 0 0 0,该项目作为Cst 0 0 0 0 0 0 0 0 0 0,该项目作为Cst 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,该项目作为Cst 0.Cst 0.Cst的客户作为Cst客户作为Cst2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0_0 uu0 u0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0升级为Cst10,此为Cst11,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst13,此为Cst13,此为Cst13,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst13,此为Cst14,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst12,此为Cst12接收系统中的数据,不存在。CLEORA42表:CLEORA:CLEORA视图:CLEORA

他试图运行的查询是由FluentNHibernate自动生成的。如果我删除了查询正确执行的部分,它就会得到结果。问题是我无法按照我的意愿更改查询。可能问题是我们使用的是Oracle 11 g,而FluentNHibernate仅调整为Oracle 9或10


将通知任何帮助。

我以前的回答不正确。请允许我再试一次

在Oracle中引用对象名称时,它会区分大小写。您的CUSTOMER表被引用为CUSTOMER,这与被引用为CUSTOMER不同:

SQL> select * from "dual";
select * from "dual"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "Dual";
select * from "Dual"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "DUAL";

D
-
X
我仍然对Fluid NHibernate一无所知,但是否可以让它查找客户表而不是客户表

或者,如果没有其他人在查找CUSTOMERS表,您可以将其重命名为CUSTOMERS…但是,这将中断对CUSTOMERS表的引用:

SQL> create table CUSTOMERS (x int);

Table created.

SQL> insert into CUSTOMERS (x) values (1);

1 row created.

SQL> select * from CUSTOMERS;

         X
----------
         1

SQL> select * from "Customers";
select * from "Customers"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "CUSTOMERS";

         X
----------
         1

SQL> alter table CUSTOMERS rename to "Customers";

Table altered.

SQL> select * from CUSTOMERS;
select * from CUSTOMERS
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "Customers";

         X
----------
         1

祝你好运!我希望这有帮助…

你不需要为数据库的每个查询创建会话工厂。创建一次,然后让它每次为你返回会话。您好。感谢您的回答。问题不在于SeesionFascory,而在于正在以不正确的方式构建的查询。问题是为什么以及如何调整因此,我会得到客户实体。当然,在概念验证之后,我会改变方法。哇。我刚刚将实体的文件名重构为customer.cs,查询成功了。非常感谢。它确实有帮助。解决这个问题的最后一个方法是,根据需要调用映射文件和实体文件,只需添加内部映射即可文件,在构造函数表中RightTableNameAsAppearSindb将修复它。
SQL> select * from "dual";
select * from "dual"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "Dual";
select * from "Dual"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "DUAL";

D
-
X
SQL> create table CUSTOMERS (x int);

Table created.

SQL> insert into CUSTOMERS (x) values (1);

1 row created.

SQL> select * from CUSTOMERS;

         X
----------
         1

SQL> select * from "Customers";
select * from "Customers"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "CUSTOMERS";

         X
----------
         1

SQL> alter table CUSTOMERS rename to "Customers";

Table altered.

SQL> select * from CUSTOMERS;
select * from CUSTOMERS
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "Customers";

         X
----------
         1