Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 474.6k

CyrstalReport DataSet doe not support Nullable?

Jul 20 2020 4:56 AM
Hi Team
 
I have a controller and getting an error "DataSet does not support System.Nullable" How can i solve this issue?
 
  1. // Controller  
  2. public ActionResult Download_XMLReport()  
  3.         {  
  4.             eNtsaRegistration context = new eNtsaRegistration();  
  5.   
  6.             ReportDocument rpt = new ReportDocument();  
  7.             rpt.Load(Path.Combine(Server.MapPath("~/Reports"), "AcademyReports.rpt"));  
  8.             rpt.SetDataSource(db.TrainingRegs.ToList());  // DataSet Does not support system.nullable??
  9.             Response.Buffer = false;  
  10.             Response.ClearContent();  
  11.             Response.ClearHeaders();  
  12.   
  13.             rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;  
  14.             rpt.PrintOptions.ApplyPageMargins(new CrystalDecisions.Shared.PageMargins(5, 5, 5, 5));  
  15.             rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA5;  
  16.   
  17.             Stream stream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);  
  18.             stream.Seek(0, SeekOrigin.Begin);  
  19.   
  20.   
  21.   
  22.   
  23.             return File(stream, "application/xml""eNtsaReportTrainingForm.xml");  
  24.         }  
  25.   
  26. // Model DbContext  
  27. public class eNtsaRegistration:DbContext  
  28.     {  
  29.   
  30.         public eNtsaRegistration() : base("eNtsaRegistration")  
  31.         {  
  32.         }  public DbSet<TrainingRegForm> TrainingRegs { getset; }  
  33.   
  34.         protected override void OnModelCreating(DbModelBuilder modelBuilder)  
  35.         {  
  36.             Database.SetInitializer<eNtsaRegistration>(null);  
  37.             base.OnModelCreating(modelBuilder);  
  38.         }  
  39.     }  
  40. // Table-Definition  
  41. public class TrainingRegForm  
  42.     {  
  43.         [Key]  
  44.         public Guid? Id { getset; }  
  45.         public string Title { getset; }  
  46.         public string FirstName { getset; }  
  47.         public string LastName { getset; }  
  48.         public string Position { getset; }  
  49.         public string Company { getset; }  
  50.   
  51.         public string StreetAddress { getset; }  
  52.   
  53.         public string StreetAddressLine { getset; }  
  54.   
  55.         public string City { getset; }  
  56.         public string StateProvince { getset; }  
  57.   
  58.         public int ZipCode { getset; }  
  59.   
  60.         public string Email { getset; }  
  61.   
  62.         [Required(ErrorMessage = "This field is required")]  
  63.         [DataType(DataType.PhoneNumber)]  
  64.         public string CellNumber { getset; }  
  65.         public string DietaryRequirement { getset; }  
  66.     }  
 

Answers (1)