Hi
I am trying to use the jquery DataTables plugin for my system, using a webservice to populate the data through an ajax call.
What I need to return from the webservice is a List like this: List<List<string>>;
I have about 120 different domain classes being used by this as the core data objects, so I need some kind of system where I can get the data from the different domain classes and transform them into List<List<string>>
in a somewhat automatic way.
The way I am getting the data is something like this (example code):
List<Core.Room> coreDataList = Core.GetRoomsInHotel(int hotelID);
I have been looking into DynamicLinq and System.Reflection, but have gotten nowhere :(
UPDATE:
What I need to return from the webservice is an array like this:
[
["data-col-1","data-col-2","data-col-3","data-col-4"],
["data-col-1","data-col-2","data-col-3","data-col-4"],
["data-col-1","data-col-2","data-col-3","data-col-4"]
]
To populate this array, I have about 120 different lists of domain classes with different properties, and I need to access those properties for each one dynamically:
For a room, based on an object looking like this:
public class Room {
public int ID { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public string LongName { get; set; }
}
[
["ID", "Double","DBL"],
["ID", "Single","SNG"],
["ID", "Suite","SUI"]
]
For a hotel:
public class Hotel {
public int ID { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public int RoomCount { get; set; }
public int FloorCount { get; set; }
}
[
["1","Plaza","153","12"],
["2","Astoria","568","25"]
]
I have a XML file with config for the lists:
<list id="29">
<readable_name>Hotels - Roomtypes - List all roomtypes in system</readable_name>
<no_data_message>No roomtypes found</no_data_message>
<cols>
<col width="0" visible="false" datafield="ID" type="key" headertext="ID" />
<col width="70" visible="true" datafield="Name" type="string" headertext="Name" />
<col width="30" visible="true" datafield="Type" type="string" headertext="Type" />
</cols>
</list>
So I pull the config from the XML file based on which list I want to load. I call the data store based on the list ID, and get a list of whatever domain class I want (Room/Hotel). I go through the returned list and produce kind of array so that the list on the page can be populated.
I hope this clarifies things a bit ...