Hello,
we currently have the following problem:
There is a table named ST_Classification and one named ST_Address, which have the following relationship:
ST_classification.PK_classification -> ST_Address.FK_classification
In a WPF-Application there is a DataFormComboBoxField which is populated with data from the ST_Classification table.
The moment the value is set to a new one an exception is thrown:
System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException was unhandled by user code
Message=Operation is not valid due to the current state of the object.
This is code in the xxx.designer.cs where the exception is thrown:
This is the XAML-code for the DataFormComboBoxField:
Here is the codeBehind for DataFormComboBoxField:
Thanks for any help in advance.
Greetings
Gerrit
we currently have the following problem:
There is a table named ST_Classification and one named ST_Address, which have the following relationship:
ST_classification.PK_classification -> ST_Address.FK_classification
In a WPF-Application there is a DataFormComboBoxField which is populated with data from the ST_Classification table.
The moment the value is set to a new one an exception is thrown:
System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException was unhandled by user code
Message=Operation is not valid due to the current state of the object.
This is code in the xxx.designer.cs where the exception is thrown:
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=
"_FK_classification"
, DbType=
"BigInt"
, UpdateCheck=UpdateCheck.Never)]
public
System.Nullable<
long
> FK_classification
{
get
{
return
this
._FK_classification;
}
set
{
if
((
this
._FK_classification != value))
{
if
(
this
._ST_classification.HasLoadedOrAssignedValue)
{
throw
new
System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
}
this
.OnFK_classificationChanging(value);
this
.SendPropertyChanging();
// <--- Exception is thrown!
this
._FK_classification = value;
this
.SendPropertyChanged(
"FK_classification"
);
this
.OnFK_classificationChanged();
}
}
}
This is the XAML-code for the DataFormComboBoxField:
<
telerik:RadDataForm
x:Name
=
"RDF_ST_Addresse"
ItemsSource
=
"{Binding Items, ElementName=RG_ST_Partner}"
AutoGenerateFields
=
"False"
EditEnding
=
"RDF_ST_Addresse_EditEnding"
EditEnded
=
"RDF_ST_Addresse_EditEnded"
DeletingItem
=
"RDF_ST_Addresse_DeletingItem"
ValidatingItem
=
"RDF_ST_Addresse_ValidatingItem"
AddingNewItem
=
"RDF_ST_Addresse_AddingNewItem"
AddedNewItem
=
"RDF_ST_Addresse_AddedNewItem"
>
.
.
.
<
telerik:DataFormComboBoxField
DataMemberBinding
=
"{Binding FK_classification, Mode=TwoWay}"
Name
=
"DFCMB_classification"
Label
=
"Klassifikation"
IsReadOnly
=
"False"
SelectedValuePath
=
"PK_classification"
DisplayMemberPath
=
"classification"
Initialized
=
"DFCMB_classification_Initialized"
/>
Here is the codeBehind for DataFormComboBoxField:
private
void
DFCMB_classification_Initialized(
object
sender, EventArgs e)
{
((DataFormComboBoxField)sender).ItemsSource = from p
in
goDCAddach.ST_classifications orderby p.classification select p ;
}
Thanks for any help in advance.
Greetings
Gerrit