How can I give an alias name to fields selected from a DataTable
using LINQ?
var output = dataTable.Rows.Cast<DataRow>().Select(r => new
{
alias1 = r["Column1"].ToString(),
alias2 = r["Column2"].ToString(),
alias3 = r["Column3"].ToString(),
/// etc...
});
var query =dataTable.Rows.Cast<DataRow>().Select(row => new
{
aliasName1 = row["Column1"].ToString(),
aliasName2 = row["Column2"].ToString()
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With