Combobox error: have to use selectedItem

Combobox error: have to use selectedItem

Postby afva » Thu 05 Jan 2012 14:14

Hello,

I work with VS2010 and we recently updated our Devart products to:

Devart dotConnect for Oracle 6.60.258.0
Devart Entity Developer 4.2.85.0
Devart OraDeveloper Tools 2.60

Since the upgrade, my comboBoxen don't work anymore.

I used to use them as follows:
Code: Select all
SelectedValuePath="ID"
SelectedValue="{Binding Path=GESL_ID}"

This goes wrong if I select an item, and then I select a new item.
The error comes from datasetDesigner.cs:
Code: Select all
set
            {
                if (this._GESL_ID != value)
                {
                    if (this._CT_RELA_GESLACHTEN.HasLoadedOrAssignedValue)
                    {
                        throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
                    }


I understand why this is, and if I alter the statement to:
Code: Select all
SelectedItem="{Binding Path=CT_RELA_GESLACHTEN}"

everthing works fine.

What I don't understand is why this happens now?
And do I have to change ALL MY comboboxen ?

Thank you for looking at this problem,
afva
 
Posts: 39
Joined: Thu 13 Aug 2009 21:22

Postby StanislavK » Tue 10 Jan 2012 11:22

As far as I can understand, the combo box you've described represents the reference to a related entity, but was bound to the foreign key property ('GESL_ID') instead of the navigation property ('CT_RELA_GESLACHTEN'). Am I correct?

If yes, the situation is caused by the way LinqConnect keeps consistency of the entity graph: if the navigation property was already loaded, it is not allowed to change the property that represents the corresponding foreign key. The reason is that setting the foreign key does not change the navigation property value, hence there would be no way to determine which property (the foreign key or navigation one) keeps the actual state of the object (and which value should be persisted to the database when submitting changes).

Thus, it is recommended to change navigation properties instead. In this case, the foreign key is modified as well, keeping the entity graph consistent.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby afva » Tue 10 Jan 2012 12:08

Hello StanislavK,

Thank you for your response.
You are correct. I do understand why I get this error, I do not understand why I get this error NOW, after the upgrade. Before the upgrade everything worked fine.
Can you explain what changed ?
Thank you
afva
 
Posts: 39
Joined: Thu 13 Aug 2009 21:22

Postby StanislavK » Wed 11 Jan 2012 15:22

A probable cause for this change in behaviour is that before updating you used another code generation template (e.g., the standard 'POCO' template or some custom template) to create entity classes. For example, the 'POCO' template generates entity classes ignorant of LinqConnect features (e.g., the EntityRef/EntitySet types are not used for navigation properties).
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48


Return to LinqConnect (LINQ to SQL support)