Created
October 18, 2019 17:53
-
-
Save vpetkovic/00311cac6c5213231d544153e99439db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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