Using a short live ConvesationScope you have to create a
ConversationalScope object everytime you access a lazy loaded property
or collection. This is very annoying.

example:
Class class1
{
  private Fiber f;
  public IConversation conversation = new Conversation();

  public void LoadFirstFiber()
  {
    f = Fiber.Find(1);
  }

  public void DisplayFiberComponentName()
  {
    using  (new ConversationalScope(conversation))  // this is
annoying
    {
      textbox1.Text = f.Component.Name;
    }
  }
}

am I wrong?


On 14 Ott, 09:35, "Alessandro C." <[email protected]>
wrote:
> Ok.
> Your suggestion is:
> One instance of Conversation per Form but not a ConversationScope
> instance per Form.
> I should create one instance of ConversationalScope when I need to
> make some operation on the database. This operation could be the
> simple save of one entity or a complex business operations that
> involve more methods in different classes.
> This is the same rule as the Transaction, isn't it?
>
> So I can replace the TransactionScope with ConversationalScope?
>
> Thanks again.
>
> On 14 Ott, 00:14, José F. Romaniello <[email protected]> wrote:
>
>
>
> > it was just pseudocode..-.-.-
>
> > -Conversation = ScopedConversation.
> > -ConversationACtion = ConversationScope.
>
> > 2010/10/13 Alessandro C. <[email protected]>
>
> > > I don't know ConversationAction, I have to read about it, but I guess
> > > that all the three methods are inside the same transaction. I that
> > > true?
>
> > > On 13 Ott, 23:37, José F. Romaniello <[email protected]> wrote:
> > > > Alessandro I am glad that my words help you, but let me help you a 
> > > > little
> > > > more.
>
> > > > That is a time bomb.
>
> > > > Conversation could have a long live, and wait for user interactions, a
> > > > ConversationScope is another thing and it should be short-lived, becouse
> > > it
> > > > often involves a db transaction.
>
> > > > Maybe the names of the classes are confusing, you need to think in two
> > > > differents things:
>
> > > >    -Conversation
> > > >    -ConversationAction
>
> > > > what hapens if you write this kind of code:
>
> > > > public class YourClass
> > > > {
> > > >   public IConversation conversation = new Conversation();
>
> > > >   public void SomeMethod()
> > > >   {
> > > >     using(new ConversationAction(conversation))
> > > >     {
> > > >          SomeMethodInThisClass();
> > > >          module.SomeMethodInOtherModule();
> > > >          service.SomeMethodInOtherService();
> > > >     }
> > > >   }
>
> > > > assuming that each of the afore mentioned methods does something with 
> > > > the
> > > > db.
> > > > What problem do you find with this usage?
>
> > > > }
>
> > > > 2010/10/13 Alessandro C. <[email protected]>
>
> > > > > Josè thanks for the answers, you point me in the right direction (I
> > > > > hope).
>
> > > > > May be I found a solution:
>
> > > > > If I create a ConversationalScope object in the form load (and dispose
> > > > > it when the form closes) everything seems to be ok.
> > > > > Of course If I need I can create a new ConversationalScope object for
> > > > > transaction pourpose. Following the example.
>
> > > > >        private void Form1_Load(object sender, EventArgs e)
> > > > >        {
> > > > >             conversational = new ConversationalScope(conversation);
> > > > >            dataGridView1.DataSource = Fiber.FindAll();
> > > > >         }
>
> > > > > On 13 Ott, 22:57, José F. Romaniello <[email protected]> wrote:
> > > > > > You are wrong, you don't have to pass the conversation from class to
> > > > > class,
> > > > > > and you don't need to surround every database call.
>
> > > > > > Read the documentation:
>
> > > > > > > SessionScopes are stored in a ThreadStatic stack
>
> > > > > > You must be configuring something wrong.
>
> > > > > > 2010/10/13 Alessandro C. <[email protected]>
>
> > > > > > >  As far as I know you have 2 options:
> > > > > > > or pass the conversation object from class to class
> > > > > > > or surround every call to the database with new
> > > > > > > ConversationalScope(conversation).
>
> > > > > > > Just to show I built a simple project (following there is a part),
> > > if
> > > > > > > you uncomment the (new ConversationalScode....) it works otherwise
> > > you
> > > > > > > get a lazy error.
> > > > > > > This is only a simple example, in the real world you often have a
> > > > > > > database call inside a class of the class of the class etc, ect.
>
> > > > > > >   public partial class Form1 : Form
> > > > > > >    {
> > > > > > >        protected IScopeConversation conversation = new
> > > > > > > ScopedConversation(ConversationFlushMode.OnClose);
> > > > > > >        public Form1()
> > > > > > >        {
> > > > > > >            InitializeComponent();
> > > > > > >        }
> > > > > > >        private void Form1_Load(object sender, EventArgs e)
> > > > > > >        {
> > > > > > >            dataGridView1.DataSource = Fiber.FindAll();
> > > > > > >        }
> > > > > > >        private void button1_Click(object sender, EventArgs e)
> > > > > > >        {
> > > > > > >            if (dataGridView1.SelectedRows.Count == 0)
> > > > > > >                return;
>
> > > > > > >            //using (new ConversationalScope(conversation))
> > > > > > >            //{
> > > > > > >                int id =
>
> > > Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["FiberId"].Value);
> > > > > > >                Fiber f = Fiber.Find(id);
>
> > > > > > >                label1.Text =
> > > > > > > f.CompositionFibers[0].Percentage.ToString();
> > > > > > >            //}
> > > > > > >         }
>
> > > > > > > On 11 Ott, 20:10, José F. Romaniello <[email protected]>
> > > wrote:
> > > > > > > > I am not so familiar with the castle impl. because i use the
> > > > > unhaddins
> > > > > > > > version... But the pattern is the same and i dont think you need
> > > to
> > > > > > > > pass the iconversation all over your code.
>
> > > > > > > > 2010/10/11, Alessandro C. <[email protected]>:
>
> > > > > > > > > Following the example of Markus
>
> > >http://using.castleproject.org/display/AR/Using+the+Conversation+Pattern
>
> > > > > > > > > I tried to change my application from single global session to
> > > a
> > > > > > > > > session per conversation but every time you need to hit the
> > > > > database
> > > > > > > > > you have to surround the operation with
> > > > > > > > > using (new ConversationalScope(conversation))
> > > > > > > > > {
> > > > > > > > > }
>
> > > > > > > > > more, if you have database access outside the form, for 
> > > > > > > > > example
> > > a
> > > > > > > > > method on a helper class, you have to pass the conversation to
> > > the
> > > > > > > > > class if you want that method use the same conversation as the
> > > > > form.
>
> > > > > > > > > Is that correct or there is a way to share the conversation 
> > > > > > > > > for
> > > the
> > > > > > > > > entire form thread?
>
> > > > > > > > > Thanks,
> > > > > > > > > --Alessandro
>
> > > > > > > > > --
> > > > > > > > > You received this message because you are subscribed to the
> > > Google
> > > > > > > Groups
> > > > > > > > > "Castle Project Users" group.
> > > > > > > > > To post to this group, send email to
> > > > > > > [email protected].
> > > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > > [email protected]<castle-project-users%2bun­­[email protected]>
> > > <castle-project-users%2bun­[email protected]>
> > > > > <castle-project-users%2bun­[email protected]>
> > > > > > > .
> > > > > > > > > For more options, visit this group at
> > > > > > > > >http://groups.google.com/group/castle-project-users?hl=en.
>
> > > > > > > > --
> > > > > > > > Enviado desde mi dispositivo móvil- Nascondi testo citato
>
> > > > > > > > - Mostra testo citato -
>
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the Google
> > > > > Groups
> > > > > > > "Castle Project Users" group.
> > > > > > > To post to this group, send email to
> > > > > [email protected]
> > > > > > > .
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > [email protected]<castle-project-users%2bun­­[email protected]>
> > > <castle-project-users%2bun­[email protected]>
> > > > > <castle-project-users%2bun­[email protected]>
> > > > > > > .
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/castle-project-users?hl=en.-Nascondi
> > > > > testo citato
>
> > > > > > - Mostra testo citato -
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Castle Project Users" group.
> > > > > To post to this group, send email to
> > > [email protected]
> > > > > .
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]<castle-project-users%2bun­­[email protected]>
> > > <castle-project-users%2bun­[email protected]>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/castle-project-users?hl=en.-Nascondi
> > > testo citato
>
> > > > - Mostra testo citato -
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Castle Project Users" group.
> > > To post to this group, send email to [email protected]
> > > .
> > > To unsubscribe from this group, send email to
> > > [email protected]<castle-project-users%2bun­­[email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/castle-project-users?hl=en.-Nascondi testo 
> > >citato
>
> > - Mostra testo citato -- Nascondi testo citato
>
> - Mostra testo citato -

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en.

Reply via email to