I would like to write LinQ query to the database by mapping the column names which are in an array.
I have the following column names in the array
string[] myColumns = {"CustID","FirstName","LastName","OrderID" };
Customer model has the following properties
public class Customer
{
public int CustID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
I am unable to map the columns to the Customer table using LinQ. I tried to implement the code as below code but I did not get the result.
var myResult=db.Customers.Select(x=>
new
{
myColumns[0]=x.CustID,
myColumns[1]=x.FirstName,
myColumns[2]=x.LastNmae
}).ToList();
I appreciate you help