NHibernate 配置连接到 Visual FoxPro 8.0?

发布于 2024-09-30 23:49:52 字数 147 浏览 11 评论 0原文

好奇是否有人曾经将 NHibernate 连接到 Visual Foxpro 8.0?我希望连接到遗留数据存储,并且更愿意使用 NHibernate,而不是必须手动编码所有 ADO.Net。

如果有人有 FoxPro 8 连接的配置 XML 文件示例,那就太棒了!

Curious if anyone out there has ever connected NHibernate to Visual Foxpro 8.0? I'm looking to hook into a legacy data store, and would prefer to use NHibernate vs. having to hand-code all of the ADO.Net.

If anyone has an example of the configuration XML file for a FoxPro 8 connection that would be great!

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

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

发布评论

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

评论(3

尴尬癌患者 2024-10-07 23:49:52

并找到了解决方案:

首先,我需要获取 Visual FoxPro 驱动程序(这些是 9.0,但允许我在 8.0 中工作)。

接下来,我必须按如下方式设置 NHibernate 配置。在这个项目中,我是基于目录的,因此我有一个名为 C:\Temp\VisualFox\ 的目录,其中包含我的所有 *.dbf 文件。

  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <reflection-optimizer use="false" />
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.Dialect.GenericDialect</property>
      <property name="connection.driver_class">NHibernate.Driver.OleDbDriver</property>
      <property name="connection.connection_string">Provider=VFPOLEDB;Data Source=C:\Temp\VisualFox;Collating Sequence=general</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
      <property name="show_sql">false</property>
    </session-factory>
  </hibernate-configuration>

而现在,世界一切都好!

And figured out the solution:

First, I needed to pick up the Visual FoxPro drivers (these are 9.0 but allowed me to work in 8.0).

Next, I had to set up my NHibernate config as follows. In this project I'm directory based, so I have a directory called C:\Temp\VisualFox\ that contains all of my *.dbf files.

  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <reflection-optimizer use="false" />
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.Dialect.GenericDialect</property>
      <property name="connection.driver_class">NHibernate.Driver.OleDbDriver</property>
      <property name="connection.connection_string">Provider=VFPOLEDB;Data Source=C:\Temp\VisualFox;Collating Sequence=general</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
      <property name="show_sql">false</property>
    </session-factory>
  </hibernate-configuration>

And now, all is well in the world!

一桥轻雨一伞开 2024-10-07 23:49:52

我没有完整的 XML 示例,但使用 OleDbDriverGenericDialect 应该可以帮助您入门。

I don't have a full XML example, but using the OleDbDriver along with GenericDialect should get you started.

一身骄傲 2024-10-07 23:49:52

这是我的解决方案:

var connectionString = @"Provider=VFPOLEDB.1;Data Source={0};CodePage=850".FormatWith(directory);

var cfg = new Configuration()
    .DataBaseIntegration(c =>
    {
        c.Dialect<GenericDialect>();
        c.ConnectionString = connectionString;
        c.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
        c.BatchSize = 100;
        c.Driver<OleDbDriver>();
    });

cfg.AddMapping(GetMappings());

和配置图:

public class MyClassMap: ClassMapping<MyClass>
{
    public MyClassMap(string filename)
    {
        Table("[" + filename + "]");
        Id(e => e.LineNo, m => m.Column("Line_No"));
    }
}

Here is my solution:

var connectionString = @"Provider=VFPOLEDB.1;Data Source={0};CodePage=850".FormatWith(directory);

var cfg = new Configuration()
    .DataBaseIntegration(c =>
    {
        c.Dialect<GenericDialect>();
        c.ConnectionString = connectionString;
        c.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
        c.BatchSize = 100;
        c.Driver<OleDbDriver>();
    });

cfg.AddMapping(GetMappings());

and Config maps:

public class MyClassMap: ClassMapping<MyClass>
{
    public MyClassMap(string filename)
    {
        Table("[" + filename + "]");
        Id(e => e.LineNo, m => m.Column("Line_No"));
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文