1

助けてください?私の NServiceBus エンドポイントは次のとおりです。

    public class EndpointConfig : IConfigureThisEndpoint
{
    public void Customize(BusConfiguration busConfiguration)
    {
        var windsorContainer = new WindsorContainer();
        windsorContainer.Install(new IocInstaller());

        busConfiguration.UseContainer<WindsorBuilder>(x => x.ExistingContainer(windsorContainer));

        var nhConfiguration = new NHibernate.Cfg.Configuration();
        nhConfiguration.Properties["connection.provider"] = "NHibernate.Connection.DriverConnectionProvider";
        nhConfiguration.Properties["connection.driver_class"] = "NHibernate.Driver.Sql2008ClientDriver";
        nhConfiguration.Properties["dialect"] = "NHibernate.Dialect.MsSql2008Dialect";
        nhConfiguration.GetClassMapping(typeof(ProductAchievementMap));

        busConfiguration.UsePersistence<NHibernatePersistence>().UseConfiguration(nhConfiguration);

        busConfiguration.UseSerialization<XmlSerializer>();
    }
}

私のハンドラーは次のとおりです。

    public class ProductAchievementAuditCommandHandler : IHandleMessages<ProductAchievementAuditCommand>
{
    public ISession Session { get; set; }

    public void Handle(ProductAchievementAuditCommand message)
    {
        var productAchievementAudit = new ProductAchievement
        {
            Id = Guid.NewGuid(),
            SapComId = message.SapComId,
            MessageId = message.MessageId
        }; 

        Session.Save(productAchievementAudit);
    }
}

私の流暢なマッピングは次のとおりです。

    public class ProductAchievementMap : ClassMap<ProductAchievement>
{
    public ProductAchievementMap()
    {
        Table("ProductAchievementMessage");
        Id(x => x.Id);
        Map(x => x.SapComId);
        Map(x => x.MessageId);
    }
}

私が得ているエラーは次のとおりです。ドキュメントによると、使用する必要がありますbusConfiguration.UsePersistence<NHibernatePersistence>().RegisterManagedSessionInTheContainer();public ISession Session { get; set; }ハンドラーに入る。流暢なマッピングを機能させるにはどうすればよいですか? どんな助けでも大歓迎です。

4

1 に答える 1