水晶报表和LINQ [英] Crystal Reports and LINQ
本文介绍了水晶报表和LINQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人想出了如何使用使用LINQ水晶报表到SQL?
Has anyone figured out how to use Crystal Reports with Linq to SQL?
推荐答案
您可以将您的LINQ的结果设置为列表
,你不需要严格使用数据集
的报告的setDataSource
,你可以提供一个水晶报表数据与的IEnumerable
。由于列表
从继承了IEnumerable
你可以设置您的报告的数据源到一个列表,你只需要调用 .ToList()
您的LINQ的结果集的方法。基本上是:
You can convert your LINQ result set to a List
, you need not strictly use a DataSet
as the reports SetDataSource
, you can supply a Crystal Reports data with an IEnumerable
. Since List
inherits from IEnumerable
you can set your reports' Data Source to a List, you just have to call the .ToList()
method on your LINQ result set. Basically:
CrystalReport1 cr1 = new CrystalReport1();
var results = (from obj in context.tSamples
where obj.ID == 112
select new { obj.Name, obj.Model, obj.Producer }).ToList();
cr1.SetDataSource(results);
crystalReportsViewer1.ReportSource = cr1;
这篇关于水晶报表和LINQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文