Convert IEnumberable to JSON
Convert IEnumberable to JSON
I am receiving the following error:
[code] Cannot implicitly convert type 'System.Collections.Generic.IEnumberable' to 'System.Collections.Generic.IEnumberable' An explicit conversion exists (are you missing a cast?[/code]
The code I am using is:
[code] var displayedOrganizations = filteredOrganizations.Skip(iDisplayStart).Take(iDisplayLength);
IEnumerable result = from c in displayedOrganizations
select new Organization[] { new Organization { ID = Convert.ToString(c.ID),CURR_PDD = c.CURR_PDD,NEW_PDD = c.NEW_PDD,CURR_OFFC = c.CURR_OFFC,NEW_OFFC = c.NEW_OFFC,
CURR_DIV = c.CURR_DIV, NEW_DIV = c.NEW_DIV, CURR_BRANCH = c.CURR_BRANCH, NEW_BRANCH = c.NEW_BRANCH,CURR_DEPT = c.CURR_DEPT,NEW_DEPT = c.NEW_DEPT,
CURR_DEPT_NAME = c.CURR_DEPT_NAME,NEW_DEPT_NAME = c.NEW_DEPT_NAME,ACTION = c.ACTION,USERID = c.USERID,UPDATED = c.UPDATED
}};[/code]
It works perfectly if I use:
[code] var displayedOrganizations = filteredOrganizations.Skip(iDisplayStart).Take(iDisplayLength);
var result = from c in displayedOrganizations
select new[] {
Convert.ToString(c.ID), c.CURR_PDD, c.NEW_PDD, c.CURR_OFFC, c.NEW_OFFC,
c.CURR_DIV, c.NEW_DIV, c.CURR_BRANCH, c.NEW_BRANCH, c.CURR_DEPT, c.NEW_DEPT,
c.CURR_DEPT_NAME, c.NEW_DEPT_NAME, c.ACTION, c.USERID, c.UPDATED
};
[/code]
But the code produces:
[code]{"sEcho":0,"iTotalRecords":9,"iTotalDisplayRecords":9,"aaData":[["cb9f927f-0f2e-4a5e-898b-304e4e8518fd","MS","OHR"]]} [/code]
And not the name/value pair
[code]{"sEcho":0,"iTotalRecords":9,"iTotalDisplayRecords":9,"aaData":[["ID":"cb9f927f-0f2e-4a5e-98b-304e4e8518fd","DIR":"MS","OFFC":"OHR"]]} [/code]
I would like to create the name/value pair. Can anyone help???
I apologize if this is the wrong thread to post too.
[code] Cannot implicitly convert type 'System.Collections.Generic.IEnumberable' to 'System.Collections.Generic.IEnumberable' An explicit conversion exists (are you missing a cast?[/code]
The code I am using is:
[code] var displayedOrganizations = filteredOrganizations.Skip(iDisplayStart).Take(iDisplayLength);
IEnumerable result = from c in displayedOrganizations
select new Organization[] { new Organization { ID = Convert.ToString(c.ID),CURR_PDD = c.CURR_PDD,NEW_PDD = c.NEW_PDD,CURR_OFFC = c.CURR_OFFC,NEW_OFFC = c.NEW_OFFC,
CURR_DIV = c.CURR_DIV, NEW_DIV = c.NEW_DIV, CURR_BRANCH = c.CURR_BRANCH, NEW_BRANCH = c.NEW_BRANCH,CURR_DEPT = c.CURR_DEPT,NEW_DEPT = c.NEW_DEPT,
CURR_DEPT_NAME = c.CURR_DEPT_NAME,NEW_DEPT_NAME = c.NEW_DEPT_NAME,ACTION = c.ACTION,USERID = c.USERID,UPDATED = c.UPDATED
}};[/code]
It works perfectly if I use:
[code] var displayedOrganizations = filteredOrganizations.Skip(iDisplayStart).Take(iDisplayLength);
var result = from c in displayedOrganizations
select new[] {
Convert.ToString(c.ID), c.CURR_PDD, c.NEW_PDD, c.CURR_OFFC, c.NEW_OFFC,
c.CURR_DIV, c.NEW_DIV, c.CURR_BRANCH, c.NEW_BRANCH, c.CURR_DEPT, c.NEW_DEPT,
c.CURR_DEPT_NAME, c.NEW_DEPT_NAME, c.ACTION, c.USERID, c.UPDATED
};
[/code]
But the code produces:
[code]{"sEcho":0,"iTotalRecords":9,"iTotalDisplayRecords":9,"aaData":[["cb9f927f-0f2e-4a5e-898b-304e4e8518fd","MS","OHR"]]} [/code]
And not the name/value pair
[code]{"sEcho":0,"iTotalRecords":9,"iTotalDisplayRecords":9,"aaData":[["ID":"cb9f927f-0f2e-4a5e-98b-304e4e8518fd","DIR":"MS","OFFC":"OHR"]]} [/code]
I would like to create the name/value pair. Can anyone help???
I apologize if this is the wrong thread to post too.
This discussion has been closed.
Replies
Allan