Column.DataType = System.Object

RobEmDee

Well-known member
Joined
Mar 25, 2003
Messages
130
Location
Richmond, VA
I have a DataTable in my DataSet in which there is a column that serves as temporary storage for data. In order to put any kind of DataType in there (for ease of managability), I have made the columns DataType System.Object. Everything works great.....I can stick anything thing in there and retrieve it back into a its specific data type without explicitly Casting. I assume that this is because all Data Types are derived from System.Object. I am concerned because generally in my development experience when something is this easy, you are paying the price somewhere. Could someone more experienced than I point out inefficiencies or a better way to do this? Thanks!
 
All depends. What are the different data types that youre putting in there and how big are they if theyre not standard types? How is this DataSet ultimately being used (an SQL insert/update possibly)? How many rows are there?
 
The Data Types will be 15% String 85% Double. The DataSet is only being used for an in-memory data cache. One DataSet worth of Data (8 tables) represents one Linear Programming Models worth of data. I am using table #9 (the one discussed in this thread) to capture DataColumn changes (TableName, ColumnName, PrimaryKey, (Original value and Current Value - System.Object Types)) and give the user the option to reset them or submit them at different points in the app. I have my own updating, inserting, and deleting logic because of the nature of the LP Model. I want to use one table to capture changes so that I dont have to have 8 Changes tables for each representative Model Object (DataTable) in the Dataset.
 
Id only point out that using extra columns can be a great benefit if thats really what you need. Since youre not saving this dataset to a database - internal cache only you said - then theres no network performance with passing this extra data around. If you really need to store the column so that you have the data PER ROW, then thats probably the best route to go. If your table only has one row for saving values, then maybe you want something else - either a custom object or even a Hashtable (both of which would be more lightweight memory-wise than a DataTable).

-Nerseus
 
Back
Top