我的數據來自我的ASP.NET頁面上的實體數據模型表。 現在我必須將這些數據導出到按鈕點擊的Excel中。如何使用LINQ to Entity將數據導出到Excel?
如果使用OLEDB,它是直線前進,因爲它是在這裏:http://csharp.net-informations.com/excel/csharp-excel-oledb-insert.htm
這裏是我的函數從查詢表中讀取數據:
var model = from i in myEntity.Inquiries
where i.User_Id == 5
orderby i.TX_Id descending
select new {
RequestID = i.TX_Id,
CustomerName = i.CustomerMaster.FirstName,
RequestDate = i.RequestDate,
Email = i.CustomerMaster.MS_Id,
DocDescription = i.Document.Description,
ProductName = i.Product.Name
http://www.hanselman.com/blog/BackToBasicsKeepItSimpleAndDevelopYourSenseOfSmellFromLinqToCSV.aspx – 2010-02-05 13:38:19