||

On Tue, Jan 11, 2011 at 2:48 PM, Børgi <[email protected]> wrote:

> Hi folks!
>
> I have a question concerning the CpBT approach suggested in the
> NHibernate 3.0 Cookbook (chapter "Using the Conversation per
> BusinessTransaction pattern").
>
> Here the two classes I'm toying around with:
>
> 1) The Worker class:
>  [PersistenceConversational(
>        MethodsIncludeMode=MethodsIncludeMode.Implicit,
>        DefaultEndMode=EndMode.Continue)]
>    public class Worker1
>    {
>        private IDao<ToDoAction> _ToDoActionDao;
>
>        public Worker1(IDao<ToDoAction> toDoActionDao)
>        {
>            _ToDoActionDao = toDoActionDao;
>        }
>
>        public virtual void ListAll()
>        {
>            var list = _ToDoActionDao.RetrieveAll().ToList();
>                foreach (var item in list)
>                    System.Console.WriteLine(item.ToString());
>        }
>
>        public virtual void AddNew()
>        {
>            ToDoAction a = new ToDoAction()
>            {
>                CreatedAt = DateTime.Now,
>                CompleteBy = DateTime.Now,
>                Content = "abc",
>                Status = Status.Finished,
>                Title = DateTime.Now.ToShortTimeString(),
>            };
>            _ToDoActionDao.Save(a);
>        }
>
>        public virtual void UpdateTitles()
>        {
>            var list = _ToDoActionDao.RetrieveAll();
>            foreach(var item in list)
>                item.Title += "!";
>        }
>
>        [PersistenceConversation(ConversationEndMode = EndMode.End)]
>        public virtual void SaveChanges()
>        {
>        }
>
>        [PersistenceConversation(ConversationEndMode=EndMode.Abort)]
>        public virtual void Abort()
>        {
>        }
>    }
>
> 2) The calling method in another class:
> protected override void OnStartup(StartupEventArgs e)
> {
>                        //Presenters.Show("Main");
>
>
> BootStrapper.Container.Register(Castle.MicroKernel.Registration.Component.For<Worker1>().LifeStyle.Transient);
>
>            var w = BootStrapper.Container.GetService<Worker1>();
>            w.AddNew();
>            w.ListAll();
>            w.Abort();
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to