DataSet does not support System.Nullable<>
Posted
by a_m0d
on Stack Overflow
See other posts from Stack Overflow
or by a_m0d
Published on 2010-06-14T06:39:01Z
Indexed on
2010/06/14
6:42 UTC
Read the original article
Hit count: 1378
I'm trying to set the DataSource for a Crystal Reports report, but I've run into a few problems. I've been following a guide written by Mohammad Mahdi Ramezanpour, and have managed to get all the way to the last part now (setting the DataSource). However, I have a problem that Mohammad does not seem to have - when I pass the results of my query to the report, I end up with the following exception:
DataSet does not support System.Nullable<>
This is the query I am using:
public IQueryable<Part> GetPartsToDisplayOnStockReport()
{
return from part in db.Parts
where part.showOnStockReport == true
select part;
}
and the way I pass it to the Report:
public ActionResult ViewStockReport()
{
StockReport stockReport = new StockReport();
var parts = ordersRepository.GetPartsToDisplayOnStockReport().ToList();
stockReport.SetDataSource(parts);
Stream stream = stockReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
return File(stream, "application/pdf");
}
I have also tried changing my query to this code, in the hope that it would fix my problem:
return (from part in db.Parts
where part.showOnStockReport == true
select part) ?? db.Parts.DefaultIfEmpty();
but it still complained about the same problem.
How can I pass the results of this query to my report, to use it as a data source? Also, if each of my Part
s object contains other objects / collections of other objects, will I be able to reference them in the report with a datasource like this?
© Stack Overflow or respective owner