I would like convert DataTable in ObservableCollection without having a specific class in my solution. (All others solution in stackoverflow.com is with specific class.)
The reason is that the DataTable represent a Stored Procedure Result, and in the future I would like change the Stored Procedure result without any change in the application.
I can't bind directly my DataBale because I use Filter on my ModelView side, and I have an exception if I use DataTable and Filter together.
Any idea ?
Thanks
The goal îs to have the same code, but without BO.Line object.
static public ObservableCollection<BO.Line> GetValues()
{
DataTable _dataTable = DAL.ExecuteStoredProcedure(GetStoredProcedureNameInAppConfig());
ObservableCollection<BO.Line> _list = new ObservableCollection<BO.Line>();
foreach (DataRow _dataRow in _dataTable.Rows)
{
_list.Add(new BO.Line() { Instrument = _dataRow["Instrument"].ToString(),
Crystal = _dataRow["Crystal"].ToString() });
}
return _list;
}
In this sample:
GetStoredProcedureNameInAppConfig() //return "GetLines"
but i would like change in my App.config (without recompile my application):
GetStoredProcedureNameInAppConfig() //return "GetPerson"
"GetLines" Stored Procedue return:
Instrument | Crystal
______________________
Instr1 | Crystal1
Instr1 | Crystal2
Instr2 | Crystal1
"GetPerson" Stored Procedue return:
FirstName | LastName | Language
_______________________________
Alex | Doe | ENG
Britt | Nillis | ENG
Carlo | Petro | FR
Resume
I would like convert DataTable (with variable structure) in "generic" ObservableCollection. Witout specific class.
(ObservableCollection isn't good solution for me.)
Thank you