CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

SagaPersister

312 Views
Copy Code Show/Hide Line Numbers
public class FluentSagaPersister : ISagaPersister
{
    /// <summary>
    /// Injected session factory.
    /// </summary>
    public ISessionFactory SessionFactory { get; set; }
 
    #region ISagaPersister Members
 
    public void Save(ISagaEntity saga)
    {
        SessionFactory.GetCurrentSession().Save(saga);
    }
 
    public void Update(ISagaEntity saga)
    {
        SessionFactory.GetCurrentSession().Update(saga);
    }
 
    public T Get<T>(Guid sagaId) where T : ISagaEntity
    {
        
        return SessionFactory.GetCurrentSession().Get<T>(sagaId);
    }
 
    public T Get<T>(string property, object value) where T : ISagaEntity
    {
        return SessionFactory.GetCurrentSession().CreateCriteria(typeof (T))
            .Add(Restrictions.Eq(property, value))
            .UniqueResult<T>();
    }
 
    public void Complete(ISagaEntity saga)
    {
        SessionFactory.GetCurrentSession().Delete(saga);
    }
 
    #endregion
}
by Mikael Henriksson
  September 20, 2009 @ 3:48am
Tags:
Description:
My custom saga persister for nservicebus using fluent nhibernate.

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate