質問

私はとの問題を抱えています

NHibernate.Cfg.Configuration.SetProperties()

のIDictionaryを受け付けない:NHibernateConfigHandler

私はメッセージを取得ます:

エラー30 'NHibernate.Cfg.Configuration.SetProperties(System.Collections.Generic.IDictionary)' の最良のオーバーロードされたメソッドの一致

いくつかの無効な引数を持っています

エラー31引数 '1': 'にSystem.Collections.IDictionary' から変換することはできません 'System.Collections.Generic.IDictionary'

教えてください?

<時間>

全体方法:

/// <param name="config">NHibernate configuration</param>
public ISessionFactory GetSessionFactoryFor(NHibernateConfigHandler config)
{
if (config == null)
    throw new ArgumentNullException("config may not be null nor empty");

ISessionFactory sessionFactory = GetSessionFactoryFor(config.MappingAssembly);

//  Failed to find a cached SessionFactory so make a new one.
if (sessionFactory == null)
{
    NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();

    cfg.SetProperties(config.Properties); //THIS LINE

    cfg.AddAssembly(config.MappingAssembly);

    //  Now that we have our Configuration object, create a new SessionFactory
    sessionFactory = cfg.BuildSessionFactory();

    if (sessionFactory == null)
    {
        throw new InvalidOperationException("cfg.BuildSessionFactory() returned null.");
    }

    HttpRuntime.Cache.Add(config.MappingAssembly, sessionFactory, null, DateTime.Now.AddDays(7),
        TimeSpan.Zero, CacheItemPriority.High, null);
}

return sessionFactory;

}

役に立ちましたか?

解決

のsetPropertiesの署名である

public NHibernate.Cfg.Configuration SetProperties(System.Collections.Generic.IDictionary<string,string> newProperties)
    Member of NHibernate.Cfg.Configuration

のsetPropertiesはタイプのIDictionaryのパラメータ、すなわち一般的な辞書を取っています。そして、あなたがたIDictionaryに渡ししようとしています。エラーの理由のthatsます。

あなたはSystem.Collections.Generic.IDictionaryにNHibernateConfigHandlerにおけるプロパティのタイプを変更することができます。 または System.Collections.Generic.IDictionaryを作成し、System.Collections.IDictionaryからすべての値をコピーします。

これは、(にSystem.Collectionsである)IDictionaryを上(System.Collections.Genericである)の一般的な辞書を使用することが常に効率的です。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top