OnInsertPre & OnUpdatePre

1 view
Skip to first unread message

pandelis

unread,
Nov 14, 2009, 2:18:50 AM11/14/09
to CslaGenerator
I was just wondering why do these events fire after the DoInsertUpdate
(cmd) and not before that part. Not that i cant create another event
or move them myself, but i was just wondering whether it would be
better to have them before DoInsertUpdate(cmd). The reason behind my
thinking is that i use these events mostly for changing object
properties, but then again people could be using it to get other
useful information (i havent used enterprise services or asp with csla
so i cant really be sure).

Tiago

unread,
Nov 14, 2009, 6:52:37 AM11/14/09
to CslaGenerator
That is an excellent point! I need to set the changed user and date
and found the same problem. My customized copy os CslaGen generates 3
events:
- onInsertStart
- onInsertPre
- onInsertPost
like this:

onInsertStart(this, EventArgs.Empty);
DoInsertUpdate(cmd);
onInsertPre(this, EventArgs.Empty);
...

Maybe the name onInsertStart isn't the best choice and it should be he
other way around...

Andrés Villanueva

unread,
Nov 14, 2009, 1:20:27 PM11/14/09
to cslage...@googlegroups.com
The reasoning for the current order is that you may want your object
properties as they are, but send something different to sql. The
current place event lets you do all operations:
-Change the property but not the SqlParameter.
-Change the SqlParameter but not the property.
-Change both, albeit in two steps for this specific scenario.

Anyway, this issue has been brought up enough times and I've been
considering adding a few more events to cover all the cases. It's very
likely that next version will include new hooks.
A good reason to add a new one is that we can add it before the check
for MyBase.IsDirty, allowing you to force the update if necessary.
> --
> http://groups.google.com/group/CslaGenerator
> Post to: CslaGe...@googlegroups.com
> Unsuscribe: CslaGenerato...@googlegroups.com
> Join us on #CslaGenerator @ irc.freenode.net



--
Andrés

pandelis

unread,
Nov 16, 2009, 6:42:36 AM11/16/09
to CslaGenerator
good points there!
Reply all
Reply to author
Forward
0 new messages