473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DataTable does not merge user defined objects

1
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.Rows[0][5]
false

(Position)this.data.Rows[1][5]==(Position)this.data.Rows[0][5]
true

this.data.Rows[1][5].Equals(this.data.Rows[0][5])
true

this.data.Rows[1][5].GetHashCode()
-461267399
this.data.Rows[0][5].GetHashCode()
-461267399

this.data.Columns[5]
{PositionX}
base {System.ComponentModel.MarshalByValueComponent}: {PositionX}
AllowDBNull: false
AutoIncrement: false
AutoIncrementSeed: 0
AutoIncrementStep: 1
Caption: "PositionX"
ColumnMapping: Element
ColumnName: "PositionX"
DataType: {Name = "Position" FullName = "TiloW.Parameter.Position"}
DateTimeMode: UnspecifiedLocal
DefaultValue: {}
Expression: ""
ExtendedProperties: Count = 1
MaxLength: -1
Namespace: ""
Ordinal: 5
Prefix: ""
ReadOnly: false
Table: {}
Unique: false
Apr 16 '10 #1
0 1180

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bubby | last post by:
Should I be concerned about the classic "Deep/Shallow" copy problem when returning objects, specifically a DataTable or DataView from a method? For example, see the code below: private...
4
by: Kris Rudin | last post by:
I am displaying a table of information on a web page, using an asp:table that I populate dynamically. On this page I give the user the options to group the rows by certain fields, and/or filter the...
11
by: Bruce D | last post by:
I have a DataTable that I need to merge the 'lastname' and 'firstname' fields to be displayed in a datagrid. I know I can use the SQL statement to merge the fields into one, but I want to know if...
2
by: deko | last post by:
This is something of a design question. I have WinForms app that requires persisting a bunch of user settings. The app maintains a number of "Projects" that contain a variety of parameters,...
9
by: Pascal Berger | last post by:
What's the fastest way to accomplish the following tasks: - Copy all data from one DataTable to another. Currently I work with CreateDataReader() / Load(). Is there any faster approach? - Add a...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
2
by: =?Utf-8?B?Sm9iIExvdA==?= | last post by:
How can I reconcile changes between two data table and create a subset of those changes. I have two data tables with same schema which gets populated from two different xml files. I want to get...
1
by: mj2736 | last post by:
I'm a little confused about DataTable.Merge(). I have two DataTable objects with the same structure - dtOrig and dtCurrent. The end result I'm trying to achieve is to get all the rows in dtCurrent...
3
by: Steve B. | last post by:
Hi, I'm building an ASP.Net corportate web application. One module of the application consists of a web service that manages users. Due to the history of the organisation, there is several...
6
by: laredotornado | last post by:
Hi, I'm using PHP 5. I have $this->m_pages_arr = array_merge($this->m_pages_arr, $p_file_obj- in which "$this->m_pages_arr" is an array and $p_file_obj is an object I defined. What I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.