I got a problem with a DataTable handling an object defined by myself (Position).
The object stores some data and overwrites ToString, Equals and GetHashCode. Further it provides the static operators for == and !=.
The DataTable works fine as long the column storing this object is not a key column. Setting it as a PrimaryKey and merge another table to it fails, because the content will not found equal. (Suppricing the datagridview and the DataTable itself finds the data violating the key after merging.)
Attached you'll find some manual comparison of the data after merging.
Has anybody an idea how to deal with that?
Best regards, Tilo
this.data.Rows[1][5]==this.data.Row s[0][5]
false
(Position)this. data.Rows[1][5]==(Position)thi s.data.Rows[0][5]
true
this.data.Rows[1][5].Equals(this.da ta.Rows[0][5])
true
this.data.Rows[1][5].GetHashCode()
-461267399
this.data.Rows[0][5].GetHashCode()
-461267399
this.data.Colum ns[5]
{PositionX}
base {System.Compone ntModel.Marshal ByValueComponen t}: {PositionX}
AllowDBNull: false
AutoIncrement: false
AutoIncrementSe ed: 0
AutoIncrementSt ep: 1
Caption: "PositionX"
ColumnMapping: Element
ColumnName: "PositionX"
DataType: {Name = "Position" FullName = "TiloW.Paramete r.Position"}
DateTimeMode: UnspecifiedLoca l
DefaultValue: {}
Expression: ""
ExtendedPropert ies: Count = 1
MaxLength: -1
Namespace: ""
Ordinal: 5
Prefix: ""
ReadOnly: false
Table: {}
Unique: false
The object stores some data and overwrites ToString, Equals and GetHashCode. Further it provides the static operators for == and !=.
The DataTable works fine as long the column storing this object is not a key column. Setting it as a PrimaryKey and merge another table to it fails, because the content will not found equal. (Suppricing the datagridview and the DataTable itself finds the data violating the key after merging.)
Attached you'll find some manual comparison of the data after merging.
Has anybody an idea how to deal with that?
Best regards, Tilo
this.data.Rows[1][5]==this.data.Row s[0][5]
false
(Position)this. data.Rows[1][5]==(Position)thi s.data.Rows[0][5]
true
this.data.Rows[1][5].Equals(this.da ta.Rows[0][5])
true
this.data.Rows[1][5].GetHashCode()
-461267399
this.data.Rows[0][5].GetHashCode()
-461267399
this.data.Colum ns[5]
{PositionX}
base {System.Compone ntModel.Marshal ByValueComponen t}: {PositionX}
AllowDBNull: false
AutoIncrement: false
AutoIncrementSe ed: 0
AutoIncrementSt ep: 1
Caption: "PositionX"
ColumnMapping: Element
ColumnName: "PositionX"
DataType: {Name = "Position" FullName = "TiloW.Paramete r.Position"}
DateTimeMode: UnspecifiedLoca l
DefaultValue: {}
Expression: ""
ExtendedPropert ies: Count = 1
MaxLength: -1
Namespace: ""
Ordinal: 5
Prefix: ""
ReadOnly: false
Table: {}
Unique: false