Gcobani Mkontwana

Gcobani Mkontwana

  • 560
  • 1.9k
  • 410.9k

Cannot be constructed to Linq

Jul 22 2020 6:55 AM
Hi Team
 
 I am experience this problem below and my table definition is as follows;
  1. // Model  
  2. public class eNtsaRegForm  
  3.     {  
  4.         [Key]  
  5.         public int Id { getset; }  
  6.         public string Title { getset; }  
  7.         public string FirstName { getset; }  
  8.         public string LastName { getset; }  
  9.         public string Position { getset; }  
  10.         public string Company { getset; }  
  11.         public string StreetAddress { getset; }  
  12.         public string StreetAddressLine { getset; }  
  13.         public string City { getset; }  
  14.         public string StateProvince { getset; }  
  15.         public int ZipCode { getset; }  
  16.         public string Country { getset; }  
  17.         public string Email { getset; }  
  18.         [Required(ErrorMessage = " This field is required")]  
  19.         public int CellNumber { getset; }  
  20.         public string DietaryRequirements { getset; }  
  21.   
  22.   
  23.     }  
  24.   
  25. // Controller  
  26.  public ActionResult Download_XMLReport()  
  27.         {  
  28.             var _db = new eNtsaRegistration();  
  29.   
  30.             var data = (from q in _db.Training select new eNtsaRegForm {   
  31.             FirstName = q.FirstName  
  32.               
  33.             }).ToList(); // Error is here it can not be constructed to Linq  
  34.   
  35.             ReportDocument rpt = new ReportDocument();  
  36.             rpt.Load(Server.MapPath("~/Reports/uYiloReporting.rpt"));  
  37.             rpt.SetDataSource(data);  
  38.   
  39.   
  40.             Response.Buffer = false;  
  41.             Response.ClearContent();  
  42.             Response.ClearHeaders();  
  43.   
  44.             try  
  45.             {  
  46.                 Stream stream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);  
  47.                 stream.Seek(0, SeekOrigin.Begin);  
  48.                 return File(stream, "application/excel""eNtsaRegistrationForm.excel");  
  49.             }  
  50.             catch  
  51.             {  
  52.                 throw;  
  53.                 //return View();  
  54.             }  
  55.   
  56.              
  57.         }  
  58.          
 

Answers (1)