Meps
asked on
Dynamic Generic Data Transfer Object
This has to already exist, but I just can't find it, or don't understand what I am looking at.
Simplely put I want to do this. I want to have an object that I can use that would be generic, but dynamic at the same time.
The code snippet shows something like what I want to do. I want to create an object, tell it why datatypes I am going to use along with the names of the properties I want, and then be able to fill out the object with the values I want. So I can pass it along through the application.
So how would I create this generic DTO?
Simplely put I want to do this. I want to have an object that I can use that would be generic, but dynamic at the same time.
The code snippet shows something like what I want to do. I want to create an object, tell it why datatypes I am going to use along with the names of the properties I want, and then be able to fill out the object with the values I want. So I can pass it along through the application.
So how would I create this generic DTO?
GenDTO bob = new GenDTO();
bob.add(datetime "StartDate");
bob.add(string "Name");
bob.StartDate = '1/1/2010';
bob.Name = 'Smith';
GenDTO g123 = new GenDTO();
g123.add(int "ID");
g123.add(bool "Terminated");
g123.ID = 2;
g123.Terminated = true;
The most standard way to do this is through a dynamically defined DataTable oject.
ASKER
I don't understand, do you happen to have some example code of how I would create the class?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks