【发布时间】:2019-10-23 18:16:05
【问题描述】:
我用来构建 Crystal Report 的 TO-SQL` 查询:
private void Arrivages()
{
using(DataClasses1DataContext dc=new DataClasses1DataContext())
{
var datas = (from art in dc.FICHES_ARTICLES
join ent in dc.ENTREES_STOCKS on art.ART_CODE equals ent.ART_CODE
where art.ART_SITE == 7 && art.ART_CODE == "A34815E1"
select new
{
art.ART_CODE,
art.ART_LIBELLE1,
art.ART_LIBELLE2,
//art.ART_EAN13,
art.ART_SIGNEQ,
ent.ENTSTK_LOT,
ent.ENTSTK_PNET,
ent.ENTSTK_DTENTREE,
ent.ENTSTK_NBU,
ent.ENTSTK_DATE_DEM,
ent.ENTSTK_USER
}).ToList();
string reportPath = @"O:\GT\GT9999 - Applications\GL-T\Dossiers GL-T\Reports\Rapport1.rpt";
ReportDocument cr = new ReportDocument();
cr.Load(reportPath);
cr.SetDataSource(datas);
Cr_Viewer.ViewerCore.ReportSource = cr;
}
}
但是当我运行应用程序时出现错误:
SystemNot SupportedException : Dataset ne prend pas en charge System.Nullable.
英文留言
SystemNot SupportedException: DataSet 不支持 System.Nullable
我怎样才能摆脱这个错误?谢谢你帮助我。
【问题讨论】:
-
调试单步执行时,datas是否为空?
-
没有数据不为空,但一个字段可以有空值(ENTSTK_DATE_DEM)
-
检查您的某个类是否正在使用不可为空的属性映射可空字段。例如数据库表:ENTREES_STOCKS - 字段:ENTSTK_DTENTREE 在数据库中为 NULL,但类为 DateTime,应为“DateTime?ENTSTK_DTENTREE”。
标签: c# wpf linq-to-sql