I have a data in Excel and I have written a method to return the data but I don't know how to return them in a list. Here is my method :
public List<MyJoin> Excel(string sort, string sortDir, int rowsPerPage, int page, out int count, out string sortCriteria) {
count = 0;
sortCriteria = "";
var book = new ExcelQueryFactory("/App_Data/Northwind.xsl");
var result = from x in book.Worksheet("Orders")
select new
{
OrderID = x["OrderID"],
OrderDate = x["OrderDate"],
ShipCountry = x["ShipCountry"],
CompanyName = x["CustomerID"],
ContactName = x["CustomerID"],
EmployeeName = x["EmployeeID"],
};
var result2 = result.ToList() ;
return result2;
//return new List<MyJoin>();
}
And here are my classes :
public class MyJoin {
public int OrderID { get; set; }
public DateTime OrderDate { get; set; }
public string ShipCountry { get; set; }
public string CompanyName { get; set; }
public string ContactName { get; set; }
public string EmployeeName { get; set; }
}
result2 cannot return LINQ and I don't know how to fix it.