Has anyone figured out how to use Crystal Reports with Linq to SQL?
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;