Bound Entities not fireing EntityContentsChanged

Posts   
 
    
ZaneZ
User
Posts: 31
Joined: 21-Dec-2004
# Posted on: 20-Mar-2007 23:25:30   

Hi,

I've read a few other threads discussing this problem and I couldn't find a definite answer as to why this is happening.

I have an EntityCollection that contains some entities that are bound to textboxes. The entities are only bound to one text box at a time. In LLBLGen 1.x after I edit the textbox and change focus, binding occurs and the entity.EntityContentsChanged event is fired. Now that we have converted to LLBLGen 2.0, i'm not seeing the event firing after binding occurs (when the control loses focus).

I saw some posts referring to the EntityContentsChanged not firing if an entity is bound to 2 textboxes, however this is not the case here. I’m just looking for some explanation as to why this is occurring so I can feel better about changing all the bound entities EntityContentsChanged events to PropertyChanged events.

Thanks!

Here's a couple links to the threads I was referring to: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7526&HighLight=1 http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7176&HighLight=1

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 21-Mar-2007 08:19:43   

Now that we have converted to LLBLGen 2.0, i'm not seeing the event firing after binding occurs (when the control loses focus).

Would you please explain the above statement in details and steps to reproduce ?

Also which runtimeLibrary version are you using?

ZaneZ
User
Posts: 31
Joined: 21-Dec-2004
# Posted on: 21-Mar-2007 14:42:10   

I'm using RuntimeVersion: v2.0.50727


// This is sudo code describing what i'm doing, 

EntityCollection<PhoneEntity> col = GetEntityCollection(); // Gets EntityCollection from adaptor
col.ListChanged += new System.ComponentModel.ListChangedEventHandler(phone_ListChanged);

PhoneEntity p1 = GetPhoneEntity(col, "Mobile");  // Gets a single entity based on the type of phone to retrieve


if (textBoxMobile.DataBindings["Text"] != null){
     textBoxMobile.DataBindings.Remove(textBoxMobile.DataBindings["Text"]);
}
textBoxMobile.DataBindings.Add("Text", p1, "Name");


PhoneEntity p2 = GetPhoneEntity(col, "Home");
if (textBoxHome.DataBindings["Text"] != null){
     textBoxHome.DataBindings.Remove(textBoxHome.DataBindings["Text"]);
}
textBoxHome.DataBindings.Add("Text", p2 , "Name");

I know that the EntityContentsChanged event should fire the ListChangedEvent on the collection. I've also ran tests listening the the EntityContentsChanged event on each entity from the collection. Neither events fire when I change the text on the textbox, then click off of it to force binding using LLBLGen 2.0 when it did in 1.0. The posts that I listed above state similar problems, and I just wanted to see if you had any information for me before I went ahead and converted all of the EntityContentsChanged Events on entities bound to controls, to PropertyChanged Events.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 21-Mar-2007 14:56:23   

I'm using RuntimeVersion: v2.0.50727

That's a false RTL version, please check the following thread to know how to get the RTL version: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7717

ZaneZ
User
Posts: 31
Joined: 21-Dec-2004
# Posted on: 21-Mar-2007 17:34:33   

SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll File Version: 2.0.0703.1401

We recompiled this dll in order to incorperate SimmoTech's fast serializer. It shouldn't be affecting the way entities are bound to controls.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 21-Mar-2007 18:07:25   

If the entity is ALSO in a collection and that collection is bound to a grid and you for example select that entity and then show it into the textboxes and edit it there, the edit cycle is already started on the entity as it's started by the grid, so the grid will also have to END it.

THere are a couple of threads about this and I found out in one of them that the currencymanager apparently has hardcoded logic for a datatable, as binding a datatable will work, but binding a dataview directly also has the same effect as you see with LLBLGen Pro code.

Needless to say, this is stupid, and I wholeheartly agree. However there's little I can do. What you can do is call EndEdit on the currencymanager after the textbox loses focus. It's not pretty, but it helps. Yes, in 1.0 this worked, but in 1.0 different events were raised as .NET 2.0 introduced different events and an interface (INotifyPropertyChanged) and the latter is prefered over the 1.0 events by .NET (as in: the one event per property are considered deprecated). Another change is that in 1.0 entitycollections were bound directly to a control, while in 2.0 we bind via an entity collection.

Frans Bouma | Lead developer LLBLGen Pro