Skip to content

Instantly share code, notes, and snippets.

@vpetkovic
Created October 18, 2019 17:53
Show Gist options
  • Save vpetkovic/00311cac6c5213231d544153e99439db to your computer and use it in GitHub Desktop.
Save vpetkovic/00311cac6c5213231d544153e99439db 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 DataTableToObject()
{
DataTable search = new DataTable();
search = utilities.sql.storedProcToTable([connectionName], [StoredProecude]);
IList<CountyLookupSearch> items = search.AsEnumerable().Select(row =>
new CountyLookupSearch
{
field1 = Convert.ToInt32(row.Field<char>("field1")),
field2 = row.Field<string>("field2"),
field3 = row.Field<int>("field3"),
field4 = row.Field<string>("field4"),
field5 = row.Field<string>("field5"),
field6 = row.Field<string>("field6")
}).ToList();
}
}
public class Obj
{
public int field1 { get; set; }
public string field2 { get; set; }
public int field3 { get; set; }
public string field4 { get; set; }
public string field5 { get; set; }
public string field6 { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment