C# / Postgres / FluentNHibernate:配置 npgsql 抛出 NotSupportedException

发布于 2024-10-30 13:30:16 字数 1362 浏览 5 评论 0原文

有时我真的开始想知道我的源代码中发生了什么: 我正在尝试使用 npgsql 2.0.11.0 连接到 PostGres 9.0,我确信我已经这样做了,但是现在,我的程序在进入以下步骤时抛出 NotSupportedException

ISessionFactory sf = Fluently.Configure()
                        .Database(PostgreSQLConfiguration.PostgreSQL82
                        .ConnectionString(c => c
                        .Host("localhost")
                        .Port(5432)
                        .Database("cw")
                        .Username("cw")
                        .Password("mypass")))
                        .Mappings(x => x.FluentMappings.AddFromAssemblyOf<MyMapping>())
                        .BuildSessionFactory();

:看起来很简洁:只有一行。

at NHibernate.Dialect.Dialect.GetDataBaseSchema(DbConnection connection) in d:\CSharp\NH\nhibernate\src\NHibernate\Dialect\Dialect.cs:Line 718.

我尝试将其转录为以下内容:

ISessionFactory sf = Fluently.Configure()
                        .Database(PostgreSQLConfiguration.PostgreSQL82
                        .ConnectionString(c => c.Is("Server=localhost;Port=5432;Database=cw;User Id=cw;Password=myPass;")))
                        .Mappings(x => x.FluentMappings.AddFromAssemblyOf<CardTemplateMapping>())
                        .BuildSessionFactory();

尽管如此,结果是相同的。有人遇到过类似的问题,或者更好的是有解决办法吗?

Sometimes I really start wondering what's going on in my sourcecode:
I'm trying to connect to PostGres 9.0 using npgsql 2.0.11.0, which I'm damn sure I already did, but right now, my program throws a NotSupportedException as it steps into the following :

ISessionFactory sf = Fluently.Configure()
                        .Database(PostgreSQLConfiguration.PostgreSQL82
                        .ConnectionString(c => c
                        .Host("localhost")
                        .Port(5432)
                        .Database("cw")
                        .Username("cw")
                        .Password("mypass")))
                        .Mappings(x => x.FluentMappings.AddFromAssemblyOf<MyMapping>())
                        .BuildSessionFactory();

The Stacktrace is quite neat to look at: Just one line.

at NHibernate.Dialect.Dialect.GetDataBaseSchema(DbConnection connection) in d:\CSharp\NH\nhibernate\src\NHibernate\Dialect\Dialect.cs:Line 718.

I tried transcribing this to the following:

ISessionFactory sf = Fluently.Configure()
                        .Database(PostgreSQLConfiguration.PostgreSQL82
                        .ConnectionString(c => c.Is("Server=localhost;Port=5432;Database=cw;User Id=cw;Password=myPass;")))
                        .Mappings(x => x.FluentMappings.AddFromAssemblyOf<CardTemplateMapping>())
                        .BuildSessionFactory();

Still, the result's the same. Anybody had similar issues or - even better - a fix?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妄断弥空 2024-11-06 13:30:16

我想我最终会保持自我回答问题最多的记录。

它需要将 hbm2ddl.keywords 属性设置为 none。现在它就像一个魅力。
干杯!

 .Database(PostgreSQLConfiguration.PostgreSQL82
                        .Raw("hbm2ddl.keywords","none"));

I guess I'll end up holding a record for the most self-answered questions.

It needed the hbm2ddl.keywords property set to none. Now it works like a charm.
Cheers!

 .Database(PostgreSQLConfiguration.PostgreSQL82
                        .Raw("hbm2ddl.keywords","none"));
尝蛊 2024-11-06 13:30:16

看到你已经找到了解决方案。因此,仅提供一些背景知识:

“none”将禁用有关 RDBMS 关键字的任何操作。

关键字可用于 MsSQL、Oracle、Firebird、MsSqlCe、MySQL、SQLite、SybaseAnywhere。

由于 Postgress 不在列表中,因此必须将其设置为 None。

这里有一些信息:用 NHibernate 和 PostgreSQL 引用列名

See that you already found a solution. So just for some background:

The "none" will disable any operation regarding RDBMS KeyWords.

And the Keywords is available for MsSQL, Oracle, Firebird, MsSqlCe, MySQL, SQLite, SybaseAnywhere.

Since Postgress is not in the list it has to be set to None.

There is som info on it here: Quoting column names with NHibernate and PostgreSQL

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文