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]>
> > .
> > > > 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]>
> > .
> > 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].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.