EntityContentsChanged event fails to fire in V2

Posts   
 
    
Acky
User
Posts: 4
Joined: 05-Aug-2006
# Posted on: 05-Aug-2006 15:56:00   

The EntityContentsChanged event does not work when targetting .Net 2.0 in the code generator.

After failing, I re-generated the DAL code for .Net 1.1 which succeeded.

SelfServicing 2.0.0.0 - 12th July 2006 Runtime V2.0.0.0 Version 2.0.50727 VS.Net 2005

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 05-Aug-2006 17:40:49   

Please have a look at this thread

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5027&HighLight=1

Come back if this does not answer to query

Acky
User
Posts: 4
Joined: 05-Aug-2006
# Posted on: 05-Aug-2006 22:37:38   

Thanks Sparmar2000 for your time and effort.

The referenced thread does help overcome the 'bug' with a number of potential solutions. However, I had attempted to resolve the issues the way Otis suggested in the thread, i.e. bind to the EntityContentsChanged event, which although the most logical appears to fail in the V2.0 runtime.

I do have a work around that deals with changed form controls in the unbound manner.

Thanks again.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 06-Aug-2006 11:05:18   

That thread was posted before v2 was released. In which context do you want to have events raised? Have you also consulted the reference manual of v2 to see which events are exposed by the entity classes?

Frans Bouma | Lead developer LLBLGen Pro
Acky
User
Posts: 4
Joined: 05-Aug-2006
# Posted on: 06-Aug-2006 15:08:57   

The reference manual does indicate that the 'EntityContentsChanged' event is available. I have bound a number of TextBox controls in a windows form to an Entity and expect the event to be fired if any of the values change as outlined in this extract of the code:

private void BindSupplierToGui()
{
   ...
   tbName.DataBindings.Add("Text", _currentSupplier, "Name");
   ...
   _currentSupplier.EntityContentsChanged += new      EventHandler(_currentSupplier_EntityContentsChanged);
}

private void _currentSupplier_EntityContentsChanged(object sender, EventArgs e)
{
   // enable the save button only if the supplier's data is dirty so a save is   necessary.
   btnSave.Enabled = _currentSupplier.Fields.IsDirty;
}

The event fires as expected with the .Net 1.1 runtimes but fails with the .Net 2.0 version. Obviously, I can add changed events for each of the windows forms controls but the Entity event looked like an ideal solution for ensuring that all fields are handled.

Thanks for your response.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 06-Aug-2006 16:09:38   

Please describe EXACTLY what the setup is, or better: create a repro program as otherwise it's really hard for us to reproduce this. Repro's can be mailed to support AT llblgen.com

Frans Bouma | Lead developer LLBLGen Pro
Acky
User
Posts: 4
Joined: 05-Aug-2006
# Posted on: 06-Aug-2006 19:16:53   

I have emailed apps that reproduce the failure in .Net 2.0 and success in .Net 1.1, with source, to the support desk as requested.

Report from Franz:

The problem is caused by the fact that there's an IEditableObject's editcycle in progress in the .NET 2.0 version (I tested the .NET 2.0 code in vs.net 2005, generated new code from northwind and compiled against debug builds of the runtimes). This surpresses the EntityContentChanged event until the entity has been finalized.

I'd suggest to you to use PropertyChanged instead in .NET 2.0 for this.

Acky:

I have confirmed that the PropertyChanged event does function as expected.