Altered the logging code to something simple to see the failure:
public void OnPostInsert(PostInsertEvent @event){
if (@event.Entity is IAuditable)
{
Console.WriteLine("----write audit----");
for (int index = 0; index < @event.State.Length; index++)
Console.WriteLine("----store changes of property {0}----",
@event.Persister.PropertyNames[index]);
}}
This generates the following output:
NHibernate: INSERT INTO "Class1" (FirstName, LastName, Id) VALUES (@p0, @p1,
@p2); @p0 = 'Peter' [Type: String (0)], @p1 = 'Pan' [Type: String (0)], @p2 = 1
[Type: Int64 (0)]----write audit--------store changes of property
FirstName--------store changes of property LastName--------write
audit--------store changes of property FirstName--------store changes of
property LastName----
As you see, it's not the EventHandler code that's erroneous, but the
framework calling it that behaves unexpectedly (calling the OnPostInsert
method twice). Any ideas why this is happening?
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.