Is it possible to pass the array pf column names to LINQ ? code same is as below. Here instead of specifying column names like "FirstName", "LastName" i would like to pass array with all the required column names. Is that possible?
public static void test(System.Data.DataTable dt, string[] columns)
{
var dt2 = dt.AsEnumerable().Select(row => new
{
FirstName = row.Field<string>("FirstName"),
Title = row.Field<string>("LastName")
})
.Distinct().ToList();
}
is it possible to write something like below?
public static void test(System.Data.DataTable dt, string[] columns)
{
var dt2 = dt.AsEnumerable().Select(row => new
{
//**columns go here**
})
.Distinct().ToList();
}
Thank you.