2

我想使用域事件模式从 Factura 实体初始化一个属性。构造函数中的代码是:

public class Factura : Entity
{
    public Factura()
    {
        this.Fecha = DateTime.Now;
        this.CodigoMoneda = 2;

        DomainEvents.Raise(new NuevaFacturaEvent(this));
    }
}

处理程序中的代码是:

public class CompletarFacturaHandler: IHandles<NuevaFacturaEvent>
{
    private readonly ILinqRepository<Parametro> parametroRepository;

    public CompletarFacturaHandler(ILinqRepository<Parametro> parametroRepository)
    {
        this.parametroRepository = parametroRepository;
    }

    public void Handle(NuevaFacturaEvent nuevaFacturaEvent)
    {
        if (nuevaFacturaEvent == null)
        {
            throw new ArgumentNullException("nuevaFacturaEvent");
        }

        var ruc = parametroRepository.FindAll().Single(p => p.Codigo == 2 && p.CodigoUniversidad == 1);
        nuevaFacturaEvent.Factura.Ruc = ruc.Texto;
    }
}

但我收到以下错误:

工厂键为 nhibernate.current_session 的 ISessionFactory 不存在

我能做些什么?

4

0 回答 0