Skip to content

Instantly share code, notes, and snippets.

@vpetkovic
Last active November 5, 2019 20:35
Show Gist options
  • Save vpetkovic/e6b93bc98db319c33753055eadb8ad28 to your computer and use it in GitHub Desktop.
Save vpetkovic/e6b93bc98db319c33753055eadb8ad28 to your computer and use it in GitHub Desktop.
// Install System.Data.DataSetExtensions from NUGET
using System;
using System.Linq;
using System.Data;
public class newClass
{
public object DataSetToObject()
{
DataTable search = new DataTable();
search = utilities.sql.storedProcToTable([connectionName], [StoredProecude]);
List<object> summaryByDay = new List<object>();
foreach (DataTable tbl in ds.Tables)
{
summaryByDay.Add(
new SummaryByDay
{
date = tbl.Rows[0]["runDate"].ToString(),
summary = tbl.AsEnumerable().Select(row =>
new summary
{
DocType = row.Field<string>("DocType")
}).ToList()
}
);
}
}
}
public class SummaryByDay
{
public string date { get; set; }
public ICollection<summary> summary { get; set; }
}
public class summary
{
public string DocType { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment