How to Export data to Excel using LINQ to Entity?
- by Rita
Hi
I have the data coming from Entity Data model table on my ASP.NET page.
Now I have to export this data into Excel on button click.
If it is using OLEDB, it is straight forward as it is here: http://csharp.net-informations.com/excel/csharp-excel-oledb-insert.htm
Here is my function to read data from inquiries table:
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