我是MVC5的新手,使用Crystal报表工具时出现此错误
发生了'System.NotSupportedException'类型的异常 System.Data.dll但未在用户代码中处理
其他信息:'DataSet'不支持System.Nullable<>。
using CrystalDecisions.CrystalReports.Engine;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace CrystalReportMVC.Controllers
{
public class CustomerController : Controller
{
//DbContext
private CustomerDBEntities context = new CustomerDBEntities();
// GET: Customer
public ActionResult Index()
{
var customerList = context.Customers.ToList();
return View(customerList);
}
public ActionResult ExportCustomers()
{
List<Customer> allCustomer = new List<Customer>();
allCustomer = context.Customers.ToList();
ReportDocument rd = new ReportDocument();
rd.Load(Path.Combine(Server.MapPath("~/CrystalReports"), "ReportCustomer.rpt"));
rd.SetDataSource(allCustomer);
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf", "CustomerList.pdf");
}
}
}`