nhibernate のリポジトリと作業単位パターンを実装しました。ninject を DI として使用します。私は複数のデータベースを持っているので、異なるレポを持つ作業単位の異なる実装を持っています。IDatabaseConnection インターフェイスを作業単位に挿入するために使用します。
public interface IDatabaseConnection
{
ISessionFactory SessionFactory { get; }
}
および作業単位:
public class SomeUnitOfWork : GenericUnitOfWork
{
[Inject]
public SomeUnitOfWork(IDatabaseConnection connection)
: base(connection)
{
}
そしていくつかのリポジトリ
[Inject]
public IRepository<Transaction> Transactions { get; private set; }
[Inject]
public IRepository<Paramdef> Paramdefs { get; private set; }
[Inject]
public IRepository<Transmap> Transmaps { get; private set; }
[Inject]
public IRepository<User> Users { get; private set; }
ninject モジュールで IRepository をバインドするときに使用する GenericRepository 実装には、ISessionFactory から取得できるよりも ISession を待機する引数があります。どうすればいいですか?