Hello:
I am a member of a team using CSLA 1.3 to develop an application and was hoping for some insight into the following issue . . .
An invoice object (inherets from BusinessBase) has a child InvoiceLineItemCollection. Each time the InvoiceLineItemCollection is set, code is called that registers event handers:
public
void GetInvoiceLineItemCollection()private void RegisterChildEventHandlers()
{
_invoiceLineItemCollection.ListChanged+=new System.ComponentModel.ListChangedEventHandler(ChildCollection_ListChanged);
}
During runtime, the ChildCollection_ListChanged method does not execute when the InvoiceLineItem collection is changed. This problem does not occur when the application accesses the database directly . . . only when the data portal is used.
Any thoughts on why this may be happening?
Thanks!
Chris
The handlers will be lost during serialization / de-serialization
process. You will need to re-establish them after de-serialization.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: Chris2008
[mailto:cslanet@lhotka.net]
Sent: Monday, October 20, 2008 11:21 AM
To: Sergey Barskiy
Subject: [CSLA .NET] data portal related issue
Hello:
I am a member of a team using CSLA 1.3 to develop an application and was
hoping for some insight into the following issue . . .
An invoice object (inherets from BusinessBase) has a child
InvoiceLineItemCollection. Each time the InvoiceLineItemCollection is
set, code is called that registers event handers:
public void GetInvoiceLineItemCollection()
{
// Code that creates criteria object
Criteria criteria = new Criteria()
etc.
// Code that sets
invoice line item collection.
_invoiceLineItemCollection =
InvoiceLineItemCollection.GetInvoiceLineItemCollection(Criteria);
RegisterChildEventHandlers();
}
private void RegisterChildEventHandlers()
{
_invoiceLineItemCollection.ListChanged+=new
System.ComponentModel.ListChangedEventHandler(ChildCollection_ListChanged);
}
During runtime, the ChildCollection_ListChanged
method does not execute when the InvoiceLineItem collection is changed.
This problem does not occur when the application accesses the database
directly . . . only when the data portal is used.
Any thoughts on why this may be happening?
Thanks!
Chris
Thanks for the quick reply Sergey.
Serialization doesn't appear to be the problem because the issue occurs prior to the invoice object being saved. For example:
Invoice invoice = Invoice.GetInvoice(1);
invoice.GetInvoiceLineItemCollection()
// This line of code does not cause ChildCollection_ListChanged method to execute.
invoice.InvoiceLineItemCollection[0].Notes = "x";
Chris
I see. Does Invoice.GetInvoice() call data portal?
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: Chris2008
[mailto:cslanet@lhotka.net]
Sent: Monday, October 20, 2008 12:00 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: data portal related issue
Thanks for the quick reply Sergey.
Serialization doesn't appear to be the problem because the issue occurs
prior to the invoice object being saved. For example:
Invoice invoice = Invoice.GetInvoice(1);
invoice.GetInvoiceLineItemCollection()
// This line of code does not cause ChildCollection_ListChanged method to
execute.
invoice.InvoiceLineItemCollection[0].Notes = "x";
Chris
Yes, Invoice.GetInvoice() calls the data portal as does Invoice.GetInvoiceLineItemCollection().
Thanks,
Chris
Then you need to re-attach your events because Fetch process
will break them just as Save would.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: Chris2008
[mailto:cslanet@lhotka.net]
Sent: Monday, October 20, 2008 1:31 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: RE: data portal related issue
Yes, Invoice.GetInvoice() calls the data portal as does
Invoice.GetInvoiceLineItemCollection().
Thanks,
Chris
Thanks again for your help Sergey.
Perhaps I don't fully understand the point you're making, but it seems the event handlers are already being reattached.
When a client calls Invoice.GetInvoiceLineItemCollection, the child event handlers are reattached immediately after the _invoiceLineItemCollection is populated (see GetInvoiceLineItemCollection code listed above).
Thanks,Copyright (c) Marimer LLC