Is this a scenario for CpBT (WPF form with a list of items saved at each edit)?

10 views
Skip to first unread message

Stefano

unread,
Nov 29, 2010, 6:24:56 PM11/29/10
to uNhAddIns
I started to look at the CpBT pattern just a couple of days ago, and
it's not clear to me if the following scenario can be addressed using
it:

I have a WPF form in which there is a list of items.
Everytime I edit an item, I'd like to save it to the database, instead
of having a "Save all" button pressed just at then end (I think it's
not important if there is an explicit button that the user has to
press, or the saving operation is done automatically... what is
important is the concept).
(I know the implications of saving everytime instead of just at the
end... but it's ok in this situation)

In a situation like this, all the intermediate savings of the edited
items (that have to be committed to the database) can be handled with
a method that behaves as EndMode.CommitAndContinue?

And at the same time, a method that behaves as EndMode.End must be
called anyway?
What happens if I don't call it?
If I have to call it, I think that the close event of the form could
be a possible place... is this correct?

And another doubt (related to this): what happens if instead of using
a method that behaves as EndMode.CommitAndContinue, I use directly a
method as EndMode.End, calling in this way the End several times?
Is this wrong? I looked at Josè Romaniello's Chinook WPF sample, in
his implementation (or actually, the old one of several months ago,
described in his blog) it's possible to press the "Save All" button
several times, so the End button is called more than once... is this
ok?




José F. Romaniello

unread,
Nov 29, 2010, 6:45:38 PM11/29/10
to unha...@googlegroups.com


2010/11/29 Stefano <ste...@gmail.com>

In a situation like this, all the intermediate savings of the edited
items (that have to be committed to the database) can be handled with
a method that behaves as EndMode.CommitAndContinue?

yes, that's correct.
 
And at the same time, a method that behaves as EndMode.End must be
called anyway?
 
no, you don't need.

If I have to call it, I think that the close event of the form could
be a possible place... is this correct?

you don't need it.

And another doubt (related to this): what happens if instead of using
a method that behaves as EndMode.CommitAndContinue, I use directly a
method as EndMode.End, calling in this way the End several times?
Is this wrong? I looked at Josè Romaniello's Chinook WPF sample, in
his implementation (or actually, the old one of several months ago,
described in his blog) it's possible to press the "Save All" button
several times, so the End button is called more than once... is this
ok?

not good, because "End", flush and dispose the session... What happen if you have something in lazy state not initialized?, OTOH the next commit you will need to attach the entities (such entities were loaded in other session) to the new session.

CommitAndContinue does just what you need. If you have some problem with CommintAndContinue let us know.

 

Stefano

unread,
Nov 30, 2010, 1:50:44 AM11/30/10
to uNhAddIns
Thank you Josè, I'll try!!

On Nov 30, 12:45 am, José F. Romaniello <jfromanie...@gmail.com>
wrote:
> 2010/11/29 Stefano <ste...@gmail.com>
>
> > In a situation like this, all the intermediate savings of the edited
> > items (that have to be committed to the database) can be handled with
> > a method that behaves as EndMode.CommitAndContinue?
>
> > yes, that's correct.
> > And at the same time, a method that behaves as EndMode.End must be
> > called anyway?
>
> no, you don't need.
>
> If I have to call it, I think that the close event of the form could
>
> be a possible place... is this correct?
>
> you don't need it.
>
> And another doubt (related to this): what happens if instead of using
>
> a method that behaves as EndMode.CommitAndContinue, I use directly a
>
> method as EndMode.End, calling in this way the End several times?
>
> Is this wrong? I looked at Josè Romaniello's Chinook WPF sample, in
>
> his implementation (or actually, the old one of several months ago,
>
> described in his blog) it's possible to press the "Save All" button
>
> several times, so the End button is called more than once... is this
>
> ok?
>
> not good, because "End", flush and *dispose* the session... What happen if
Reply all
Reply to author
Forward
0 new messages