.Net Framework数据提供程序错误Fluent Nhibernate for Informix DataBase

时间:2015-03-04 14:49:02

标签: c# fluent-nhibernate autofac informix

我尝试使用AutoFac和Informix DataBase配置Fluent Nhibernate,但是出现了一个错误:

  

无法找到请求的.Net Framework数据提供程序。它可能没有安装。

工厂Nhibernate

    ISessionFactory factory = Fluently.Configure()
                                 .Database(
                       IfxSQLIConfiguration
                      .Informix1000
                      .Provider<NHibernate.Connection.DriverConnectionProvider>()
                      .Driver<NHibernate.Driver.IfxDriver>()
                      .Dialect<NHibernate.Dialect.InformixDialect>()
                      .ConnectionString(c => c.FromConnectionStringWithKey(databaseKey))
                      .ShowSql())
                      .Mappings(x => x.FluentMappings.AddFromAssemblyOf<TvLoginMapping>()
                      .Conventions.AddFromAssemblyOf<CustomTypeConvention>()
                      )
                      .BuildSessionFactory();
                factories.Add(databaseKey, factory);

WebConfig文件:

&#13;
&#13;
    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <clear />
    <add name="INFORMIX" connectionString=" Provider=Ifxoledbc.2;Password=*******;Persist Security Info=True;User ID=******;Data Source=******;Database=*****;" />
  </connectionStrings>
  
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:1)

在添加条目之前,您可能需要<clear/>

您可以检查machine.config以查看其中是否还有其他Informix。

我不认为方言是普遍的&#34;适用于您图书馆的所有版本。

请参阅: https://www.symbolsource.org/Public/Metadata/Default/Project/NHibernate/3.0.0.GA/Release/All/NHibernate/NHibernate/Dialect/InformixDialect.cs

注意班级的评论:

/// Summary description for InformixDialect.
/// This dialect is intended to work with IDS version 7.31
/// However I can test only version 10.00 as I have only this version at work
/// </summary>
/// <remarks>
/// The InformixDialect defaults the following configuration properties:
/// <list type="table">
///     <listheader>
///         <term>ConnectionDriver</term>
///         <description>NHibernate.Driver.OdbcDriver</description>
///         <term>PrepareSql</term>
///         <description>true</description>
///     </listheader>
///     <item>
///         <term>connection.driver_class</term>
///         <description><see cref="NHibernate.Driver.OdbcDriver" /></description>
///     </i

我没有&#34; Informix&#34;版眼睛。所以这只是我想的一个提示。

还要注意有这些方言:

https://www.symbolsource.org/Public/Metadata/Default/Project/NHibernate/3.0.0.GA/Release/All/NHibernate/NHibernate/Dialect/InformixDialect0940.cs?ImageName=NHibernate

https://www.symbolsource.org/Public/Metadata/Default/Project/NHibernate/3.0.0.GA/Release/All/NHibernate/NHibernate/Dialect/InformixDialect1000.cs?ImageName=NHibernate

答案 1 :(得分:1)

我使用错误的配置来使用Informix和OleDbDriver

          ISessionFactory factory = Fluently.Configure()
                                 .Database(
                       IfxSQLIConfiguration
                      .Informix1000
                      .ConnectionString("conectionString")
                      .Driver<OleDbDriver>()
                      .Dialect<InformixDialect1000>()
                        //.ConnectionString(c => c.FromConnectionStringWithKey(databaseKey))

                      .ShowSql())
                      .Mappings(x => x.FluentMappings.AddFromAssemblyOf<TvLoginMapping>()
                      .Conventions.AddFromAssemblyOf<CustomTypeConvention>()
                      )
                      .BuildSessionFactory();
                    factories.Add(databaseKey, factory);
                }

答案 2 :(得分:1)

LINQ是NHibernate的替代品之一; 并且Informix支持它。 不幸的是,Informix原生.net驱动程序没有LINQ支持。 您可能必须使用DB2 Entity Framework驱动程序来连接IDS服务器。 对于连接IDS服务器的DB2 Entity Framework驱动程序,您必须为IDS服务器启用DRDA协议。