how to get IEnumerable into a dataset |
| Johann Montfort posted at 03-Jul-08 06:11 |
Hi All,
I am trying to get the result of an IEnumerable function into a dataset, and until now, without any success.
Here is what I have done so far:-
In my DAL
public static IEnumerable<DALLINQ.projects_getAllActiveProjectsResult> GetAllActiveProjects()
{
using (var db = new DALLINQ.DataContext())
{
return db.projects_getAllActiveProjects();
}
}
Then in my code:-
public DataSet getprojects()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
foreach (var result in projects.GetAllActiveProjects())
{
dt.Rows.Add( new object[] { result.projectId, result.projectName, result.url });
}
ds.Tables.Add(dt);
return ds;
}
However this is not working
Any help very much appreciated!
Thanks |
|